<a rel="abc" href="#mydiv">link</a>
<div id="mydiv">content</div>
If rel="abc", find element with ID that matches href value and hide it.
My try:
$('[rel*=abc]').attr("href").hide();
Thanks for your help!
<a rel="abc" href="#mydiv">link</a>
<div id="mydiv">content</div>
If rel="abc", find element with ID that matches href value and hide it.
My try:
$('[rel*=abc]').attr("href").hide();
Thanks for your help!
var identifier = $('a[rel="abc"]').attr('href');
$('#'+identifier').hide();
I think this may solve your problem. I didn't test it, though.
$('a[rel=abc]').click( function(event){
event.preventDefault();
$(event.target.href.substr(event.href.indexOf('#'))).hide();
});
Hides the appropriate element if such a link is clicked.
edit: tested
$("a[rel='abc']").click(function(event){
event.preventDefault();
var val = $(this).attr("href");
$("div"+val).hide();
});
$('a[rel=abc]').each(function() {
$(this.href.substr(this.href.indexOf('#'))).hide();
});
Some error checking would be good too.
$("a[rel=abc]").each(function(i, ele) {
$(ele.hash).hide();
});
or if you want that to happen on click
$("a[rel=abc]").click(function(e) {
e.preventDefault();
$(this.hash).hide();
});