Possible Duplicates:
Is there an “exists” function for jQuery
jQuery determining if element exists on page
if(tr)
is returning true when tr is not an element, how do I check whether it's an element that exists?
var tr = $('#parts-table .no-data').parent(); $('.delete', row).bind('click', function (e) { that.delete(e.currentTarget); }); console.log(tr); if (tr) //returns true when it shouldn't
Check its length
property:
if(tr.length) { // exists }
if(tr)
always evaluates to true because a jQuery object, or any JavaScript Object for that matter, is always truthy.
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