Reputation: 3226
This is pretty simple ... but I just can't get it to work. This is what I m doing.
<li><a href="#" class="myClass" id="idOne">Click1</a></li>
<li><a href="#" class="myClass" id="idTwo">Click2</a></li>
If I click Click1 pickID
will be idOne
, but I don't know how to get the idTwo. What s the syntax for getting the id from the element with class myClass
that doesn't have the id pickID
?
$(".myClass").click(function(e) {
e.preventDefault;
var pickID = $(this).attr('id');
var notPickId = $('myClass').attr(not(pickID));// ??? this is probably so wrong ... I didn't even try it
});
Upvotes: 0
Views: 1171
Reputation: 57105
Try
var notPickId = $('.myClass').not(this).attr('id');
or
var notPickID = $('.myclass').not('#' + pickID).attr('id');
or
var notPickId = $(this).parent().siblings().find('a').attr('id');
Upvotes: 1
Reputation: 2405
another way
var pickID = $(this).attr('id');
$(".myClass[id!='" + pickID + "']").attr("id")
Upvotes: 0