猿问

如何使用 jquery 隐藏 li?隐藏()不工作

这是html代码


<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>

这是jQuery


$('#store_name').on('click', function () {

    $('#store_name_li').hide(); // not working

    var stuff = $(this).val();

    $('.emojionearea-editor').append(stuff); // working

});

这里有什么问题?


隔江千里
浏览 127回答 1
1回答

慕桂英4014372

改变,&nbsp;<li id="#store_name_li">Add your brand name. <a>{store name}</a></li>至:&nbsp;<li id="store_name_li">Add your brand name. <a>{store name}</a></li>从中删除#id="#store_name_li"。工作片段如下,$('#store_name').on('click', function () {&nbsp; &nbsp; $('#store_name_li').hide(); // not working&nbsp; &nbsp; var stuff = $(this).val();&nbsp; &nbsp; $('.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>&nbsp; &nbsp; <li id="store_name_li">Add your brand name. <a>{store name}</a></li></ul>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答