Reputation: 1276
I want to hide the following <div>
in my site pages, but this <div>
is changing its position dynamically, so I cannot use the code $("div:eq(0)").hide();
<div style="background: #ebebeb; border-top: 1px solid #ccc; border-right: 1px solid #ccc;
border-left: 1px solid #ccc; padding: 5px; font-size: 12px; position: fixed; right: 3%;
bottom: 0px; -webkit-border-radius: 3px 3px 0px 0px; border-radius: 3px 3px 0px 0px;">
Powered by <a href="http://bizmate.in">Bizmate</a></div>
Any suggestions on how can I hide that element?
Upvotes: 3
Views: 1887
Reputation: 1401
I think you'll have to assign an ID to it, and if you can't, why not?
Here's code for hiding it anyways:
JSfiddle-example
Code for hiding with id, without id, and from what your link content is:
Upvotes: 1
Reputation: 26658
try
$("a[href='http://bizmate.in']", $("#container")).closest('div').hide();
Assume in the parent elements of given html, you can find one with id="container", this will ensure the right is found with that container rather than else where since a link like that is pretty common.
Upvotes: 1
Reputation: 18233
Firstly, you really should not put all of those styles inline. It clutters your html, and is poor design since you are mixing styling and layout. It would be better to take it out, use css selectors and wrap it in <style></style>
tags; to that end you should also add a class to the <div>
to make these selections easier to carry out and more maintainable.
That being said, the following function using .filter()
will do what you want...
$("div").filter( function() {
return $(this).find("a[href^='http://bizmate.in']").length > 0;
}).hide();
Upvotes: 2
Reputation: 66663
$('div a[href="http://bizmate.in"]').parent().hide();
should work.
Demo: http://jsfiddle.net/C4pYy/
Upvotes: 2
Reputation: 1176
You can try this
$('div[style*=background: #ebebeb; [...]').hide();
Upvotes: 2
Reputation: 5094
Why not add an id and then use $('div#myId').hide()
?
<div id="myId" style="background: #ebebeb; [...]">[...]</div>
Upvotes: 1