Reputation: 73
I have a link that looks like this:
<a onclick="myLightbox" rel="lightbox" href="image.jpg" title="">
I am trying $element.prop("onclick", null);
to remove the attributes onclick
and rel
, but just don't know how to make it work
Can anyone please help me? The a tag does not have an id, and I just can't make it have one as that link is generated by a CMS i do not have control over.
Upvotes: 0
Views: 2922
Reputation: 3558
use removeAttr
$("a[href*='image.jpg']").removeAttr("rel");
Demo : http://jsfiddle.net/eFqsG/3/
Upvotes: 1
Reputation: 960
$('a').each(function(index, a) {
var a = $(a);
if(a.attr('rel') == 'lightbox' && a.attr('onclick') == 'myLightbox') {
a.attr('rel', null).attr('onclick', null);
}
});
Upvotes: 0
Reputation: 19882
Put an id or class for jquery selection or you can also select with tag like this
$('a').prop("onclick",null);
You must provide selector as $element is not recognized here.
Upvotes: 0
Reputation: 129792
rel
is not a property but an attribute. Use .removeAttr('rel')
unbind
.Upvotes: 0