//wb是WebBrowser控件, 已经实验,能获取这个网页的倒计时
HtmlElement n = wbDocumentGetElementById("jq_cur_countdown");
if (n != null)
{
string s="";
if (nChildrenCount > 1)
{
s = nChildren[0]OuterText + "分";
s += nChildren[1]OuterText + "秒";
}
else
{
s += nChildren[0]OuterText + "秒";
}
MessageBoxShow(s);
}
你说的label,可以在后台绑定,应该是服务器控件。
服务器控件在显示的时候。会被编译成HTML控件,名字等也会从新生成。
解决方法:
右键,查看页面源文件,找到从新生成后的lable。看他的名字或ID是什么。
接下来getelementbyid("新名字")innerText;就可以取到了。
jquery中parent()可以获取父级元素,所以获得某元素父级的父级可以使用
1
$(selector)parent()parent();
示例如下
创建Html代码及css样式
1
2
3
4
5
6
7
8
9
<div class="class1">
class1
<div class="class2">
class2
<div class="class3">
class3
</div>
</div>
</div>
1
2
div{padding:10px 20px;border:4px solid #ebcbbe;}
divclass1{width:200px;height:120px;}
编写jquery代码
1
2
3
4
5
6
$(function(){
$("divclass3")click(function() {
obj = $(this)parent()parent();
alert(objprop('class'));
});
})
查看效果
以上就是关于C#获取网页Label值的问题全部的内容,包括:C#获取网页Label值的问题、c#在后台成功绑定label的text值,怎么用js取到label的值的方法、jquery中的子集怎么得到父级的label标签等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)