试图修改html中的javascript变量

试图修改html中的javascript变量,javascript,jquery,html,css,string,Javascript,Jquery,Html,Css,String,我想在html中更改一个字符串,并在javascript中读取它并将其输出到屏幕。我希望在选择过滤器中写入的内容与写入屏幕的内容相同,我如何才能做到这一点 这是可以工作的原始代码,但不采用html中的字符串: $("#filter ul:eq(1) li:eq(0)").before("<li class='firstItem rounded current'><span class='firstItem'>" + $('#dow').show() +"</span

我想在html中更改一个字符串,并在javascript中读取它并将其输出到屏幕。我希望在选择过滤器中写入的内容与写入屏幕的内容相同,我如何才能做到这一点

这是可以工作的原始代码,但不采用html中的字符串:

$("#filter ul:eq(1) li:eq(0)").before("<li class='firstItem rounded current'><span class='firstItem'>" + $('#dow').show() +"</span></li>");
新HTML:

<li id="dow">
 <option data-target='div1'>Select Filter</option>
</li>
新Javascript:

 var id = $(this).find("#dow").data('target');
    $('#images > div').hide();
    console.log(id);
    $("#filter ul:eq(1) li:eq(0)").before("<li class='firstItem rounded current'><span class='firstItem'>" + $('#dow').show() +"</span></li>");
使用$dow.show最终显示元素,并再次将引用对象返回到同一元素,同时希望将该元素的普通标记连接到字符串


在连接和调用中使用$'dow'.html。在此之前显示。

为什么在?..+$中有一个内部道指“.show+。。。毫无意义。你是说用文字代替节目。show显示选定元素,而.text获取选定元素的文本内容。。。您知道jquery有一个api文档吗?谢谢,这完全符合我的需要!这正是我想要的,你帮我省去了不少麻烦,干杯。