tariqul anik
tariqul anik

Reputation: 324

How can I hide a li using jquery? hide() is not working

here is the html code

<button value="{store name}" type="button" id="store_name">{store name}</button>
<ul>
    <li id="#store_name_li">Add your brand name. <a>{store name}</a></li>
</ul>

here is the Jquery

$('#store_name').on('click', function () {
    $('#store_name_li').hide(); // not working
    var stuff = $(this).val();
    $('.emojionearea-editor').append(stuff); // working
});

what is the problem here?

Upvotes: 0

Views: 256

Answers (1)

Maniraj Murugan
Maniraj Murugan

Reputation: 9084

Change,

 <li id="#store_name_li">Add your brand name. <a>{store name}</a></li>

to:

 <li id="store_name_li">Add your brand name. <a>{store name}</a></li>

Remove # from id="#store_name_li".

Working snippet as follows,

$('#store_name').on('click', function () {
    $('#store_name_li').hide(); // not working
    var stuff = $(this).val();
    $('.emojionearea-editor').append(stuff); // working
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button value="{store name}" type="button" id="store_name">{store name}</button>
<ul>
    <li id="store_name_li">Add your brand name. <a>{store name}</a></li>
</ul>

Upvotes: 3

Related Questions