如何用js获取li标签值 30
<ulid="demo1">{dede:arclisttypeid='20'addfields='xiaoqu,huxing,mianji,jindu'channelid...
<ul id="demo1">
{dede:arclist typeid='20' addfields='xiaoqu,huxing,mianji,jindu' channelid='17'}
<li>
<p class="yangbanfang"><strong><a href="[field:arcurl/]">[field:xiaoqu function='cn_substr(@me,10)'/]</a></strong></p>
<p class="huxing"><span>[field:huxing/]</span></p>
<p class="ybfmj"><span>[field:mianji/]</span></p>
<p class="yangbanfang1"><span>[field:jindu function='cn_substr(@me,10)'/]</span></p>
<p class="canguan"><span><input type="button" class="btn" id="b" value="参观" onclick="open2()"/></span></p>
</li>
{/dede:arclist}
</ul>
点击参观在弹窗test.html中表单获取xiaoqu的梦之岛花园这个值 展开
{dede:arclist typeid='20' addfields='xiaoqu,huxing,mianji,jindu' channelid='17'}
<li>
<p class="yangbanfang"><strong><a href="[field:arcurl/]">[field:xiaoqu function='cn_substr(@me,10)'/]</a></strong></p>
<p class="huxing"><span>[field:huxing/]</span></p>
<p class="ybfmj"><span>[field:mianji/]</span></p>
<p class="yangbanfang1"><span>[field:jindu function='cn_substr(@me,10)'/]</span></p>
<p class="canguan"><span><input type="button" class="btn" id="b" value="参观" onclick="open2()"/></span></p>
</li>
{/dede:arclist}
</ul>
点击参观在弹窗test.html中表单获取xiaoqu的梦之岛花园这个值 展开
2个回答
展开全部
<li></li>标签组合肯定不止一个,它都有自己的id,比如0;我建议给<p class="yangbanfang"></p>中a标签和<p class="canguan"></p>中input标签加一个共同元素,比如<a id="a0"></a>;<input listid="0" onlick="open2(this)"></input>
function open2(obj)
{
listid = obj.getAttribute("listid");
alert(document.getElementById("a"+listid).InnerHTML());
}
要不就就<input onlick="open2(this)"></input>
function open2(obj)
{
var node_li = obj.parentNode.parentNode.parentNode;
alert(node_li .document.getElementsByTagName("a")[0].InnerHTML());
}
另外估计有的函数名我写错了,我对js不熟
function open2(obj)
{
listid = obj.getAttribute("listid");
alert(document.getElementById("a"+listid).InnerHTML());
}
要不就就<input onlick="open2(this)"></input>
function open2(obj)
{
var node_li = obj.parentNode.parentNode.parentNode;
alert(node_li .document.getElementsByTagName("a")[0].InnerHTML());
}
另外估计有的函数名我写错了,我对js不熟
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询