Reputation: 1929
I want to click .close
to remove .status-profile
but click()
does not work.
I think the problem may be a class close to be within the class status-profile.
my html:
<div class="status-profile">
<div class="message">
<span>You should complete your <b>profile.</b></span>
</div>
<div class="close">
<i class="icon-cancel"></i>
</div>
<div id="bar" class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="{res}" aria-valuemin="0" aria-valuemax="100" style="width: {res}%">
</div>
</div>
my js:
$('.status-profile .close').click(function()
{
console.log("close");
status = 100;
$(".status-profile").remove();
});
thanks to all
Problem solved: the problem was that the html is loaded trough ajax call and the class close was not yet in the DOM ... thanks
Upvotes: 0
Views: 79
Reputation: 3046
You have to subscribe to click event in document.ready:
$(function(){
$('.status-profile .close').click(function(){
console.log("close");
status = 100;
$(".status-profile").remove();
});
});
Click on "Close":
Upvotes: 1
Reputation: 51
when the js code execute the dom doesnt prepare and $('.status-profile div.close') can
t find and element
$(document).ready(function(){
dosometh
})
Upvotes: 0
Reputation: 309
Is that the exact HTML that you're using? If so, the
<div class="status-profile">
is missing its closing tag which would prevent jQuery from working as you'd expect.
Add another
</div>
right at the end and see if that helps.
Upvotes: 0