Possible Duplicate:
jQuery Selector: Id Ends With?
Suppose I have controls called ctl00_mstPartBase_lblTopPager and ctl00_mstPartBase_lblBottomPager.
These controls have many hyperlinks. I want to bind a click event for those hyperlinks. I have tried:
$('#lblTopPager #lblBottomPager a').click(function (e) {
alert("click occured");
e.preventDefault();
});
However the above code does not work because my control name is ctl00_mstPartBase_lblTopPager
How could I bind a click event with those hyperlinks when the parent control's name is not fixed, the only fixed parts are lblTopPager
and lblBottomPager
.
What code should I write such that a single click binding will work for all the hyperlinks in the two containers. Please help. Thanks
I did it in this way
$('[id$=lblTopPager] a, [id$=lblBottomPager] a').live("click", function (e) {
alert($(this).text() + ' this is my anchor text ');
e.preventDefault();
});
$(document).ready(function () { $('[id*=btnOk]').live("click", function () {
});
});