html - jquery get elements by class name -
i'm using jquery list of elements having class "x".
html:
<p class="x">some content</p> <p class="x">some content#2</p> if use jquery both these html elements , it- use like:
$(".x").text("changed text");
this change text of both paragraphs. $(".x") - how can add array - subscript notation can getelementsbyclassname follows:
document.getelementsbyclassname("x")[0].innerhtml
i tried $(".x")[0].text("asasa")- doesn't work gives typeerror in javascript console. tried api here -http://jsfiddle.net/probosckie/jnz825mp/ - , doesnt work
the error uncaught typeerror: $(...).get(...).text not function none of solutions below work!
you can way:
$('.x:eq(0)').text('changed text'); or:
$('.x').eq(1).text('bbb'); both works well
sorry before answer..
Comments
Post a Comment