I have asp.net repeater on a page. If each item being repeated is wrapped in a label like so:
<label class="ItemName">value</label>
If this label contains the text '35' I want to display some text next to it. How can i do this using jquery???
jQuery(document).ready(function () {
if ($('.ItemName').val().indexOf("35")) {
$(this).val() = $(this).val() + "some text";
}
});
.text()
should work:this you mean?
this
in the.ready
function should refer to thedocument
..text()
instead of.val()
.$obj.val(blah);
, not$obj.val() = blah;
. (This is actually a limitation of Javascript.):contains()
selector to filter elements containing some text..append()
method (Thanks @J-P for reminding this.)You may want this instead:
indexOf
returns -1 if not found, or the index. Do this: