i’m trying to add a single condition to the following Javascript that will stop the IF statement below eveluating to TRUE when user clicks inside a fieldset on the page.
I have tried allsorts but i’m guessing, I just tried adding ”
&& !(e.target.isFieldSet))” but no joy. I’ve tried searching the web, anyone any ideas?
$(function() {
$('tr').live('click', function(e) {
//if not clicking an anchor tag or imag then assume user wants to go to details page
if ((!$(e.target).is('a')) && (!$(e.target).is('img')) && (!$(e.target).is('th')) && !(e.target.isTextEdit)) {
window.location = $("#AbsolutePath").val() + 'Waste.mvc/Details/' + $(this).attr('rowid');
}
});
});
I think you’re looking for:
!$(e.target).is('fieldset'):Example: http://jsfiddle.net/zbdRT/
However, I would argue that this is unmaintainable code. What if you need to add more tags (as you’re doing right now). Something like this would be better:
or, you could store tags you want to ignore in an array that you can add to easily (this also makes the code a bit more expressive as to your intentions):