为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

隔江千里 2022-10-08 15:21:44
这是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});这里有什么问题?
查看完整描述

1 回答

?
慕桂英4014372

TA贡献1871条经验 获得超13个赞

改变,


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

至:


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

从中删除#id="#store_name_li"。


工作片段如下,


$('#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>


查看完整回答
反对 回复 2022-10-08
  • 1 回答
  • 0 关注
  • 126 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号