Reputation: 51
I have an html like this.I am trying to do a jquery trigger on a button click.Basically I just need to close the div when The button is clicked.
I have tried following code in button click using jquery but the div is not closing.Can anyone correct me
JS
$('.tags .alert-success .close').trigger(click);
HTML
<div class="sentiment-text">
<div class="wrapper">
<div class="key"></div>
<div class="text" <div class="tags alert-success"><a href="#" class="close" data-dismiss="alert">×</a><span class="noun">#</span><span class="noun">sed/span> <span class="noun">#</span><span class="noun">menshealth</span> </div></div>
<div class="clear-sentiment"></div>
</div>
</div>
Upvotes: 2
Views: 86
Reputation: 24638
This is what you need -- no space between the first two selectors -- .tags.alert-success
. Both .tags
and .alert-success
are on the same element:
$('.tags.alert-success .close').trigger( 'click' );
//or $('.tags.alert-success .close').click();
And close the opening tag of .text
div so that you have:
<div class="text"><div class="tags .......
Upvotes: 1