I want to control does an element exist in document with its ID, when page is loading. I tried code which is below, but i failed.
if($(':not(#<%=TextBox1.ClientID %>)')){
alert("Object is null")else{alert("Object is exist")}}
Thansk for your helps already now.
Read from this post (courtesy of jakemcgraw):
Is there an "exists" function for jQuery?
jQuery.fn.exists = function(){return jQuery(this).length>0;}
if ($('#<%=TextBox1.ClientID %>').exists()) {
// Do something
}
I just use directly the length property, as suggested on the jQuery FAQ:
if ($('#<%=TextBox1.ClientID %>').length) {
// Do something
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With