Below is the function that I am using in jquery
function addlnkfieldmkAndyr()
{
var mymke = $('h3:contains("Make")');
var mymkeVal= $('h3:contains("Make")').closest("td").next();
var myyr= $('h3:contains("Year")');
var myyrVal= $('h3:contains("Year")').closest("td").next();
}
The problem that is there is another field with the name as MakeandYear , so mymkeVal and myyrVal are getting the values from MakeandYear instead of just Make.
I would like to say
string.Contains("Make") && !string.Contains("MakeandYear).
How do I do that in jquery , please help!
Andrey pointed to the
.notfunction, which is a perfectly good answer. You can also use the:notselector, in combination with:contains(live example):The advantage of
:not(the selector) over.not(the function) is that you don’t add unnecessary elements to the jQuery object and then remove them. Does it matter? Almost certainly not, and be careful making any performance assumptions, although I think your use of:containsmeans throwing:notin won’t do any harm. You’d have to have a truly enormous number ofh3s for it to matter either way.