用正则匹配即可
Option ExplicitFunction GetSource$(Source$) '//正则匹配<td></td>
Dim reg As Object
Dim matchs As Object, match As Object
Dim s As String, i As Integer
Set reg = CreateObject("vbscriptregExp")
regGlobal = True
regIgnoreCase = True
regMultiLine = True
regPattern = "<label>()<\/label>"
Set matchs = regExecute(Source)
For Each match In matchs
i = i + 1
s = s & matchSubMatches(0) + vbCrLf
Next
GetSource = s
End Function
Function div$(Source$) '//正则匹配 <div></div>
Dim reg As Object
Dim matchs As Object, match As Object
Dim s As String, i As Integer
Set reg = CreateObject("vbscriptregExp")
regGlobal = True
regIgnoreCase = True
regMultiLine = True
regPattern = "<div>()<\/div>"
Set matchs = regExecute(Source)
For Each match In matchs
i = i + 1
s = s & matchSubMatches(0) + vbCrLf
Next
div = s
End Function
Private Sub Command1_Click()
MsgBox "div标签获取" + vbCrLf + GetSource$(Text1)
MsgBox "label标签获取" + vbCrLf + GetSource$(Text1)
End Sub
<lable id="content" style="height:200px;width:100px"></lable>
<lable id="lab">xxxxxx</label>
<div id="on">单击我</div>
<script>
$("#on")click(){
var labval=$("#lab")val();
$("#content")append(labval);
}
</script>
<script type="text/javascript">
function add()
{
var td1=documentgetElementById("td1");//此处开始添加label标签
var label1 = documentcreateElement("label");
label1innerHTML= '我是标签label';
var label_id = documentcreateAttribute("id");//添加label的ID值
label_idnodeValue ='label1';
label1setAttributeNode(label_id);
td1appendChild(label1);
}
function get()
{
alert(documentgetElementById("label1")id);
}
</script>
<body>
This is my HTML page
<form action="">
<table id="tab">
<tr>
<td>
<input name="add_option_btn" id="add_option_btn" type="button" class="button" onClick="add();" value="添加
标签" />
<input name="del_option_btn" id="del_option_btn" type="button" class="button" onClick="get();" value="获得
标签" />
<td>
</tr>
<tr>
<td id="td1">
<td>
</tr>
</table>
</form>
<br>
</body>
//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);
}
一般是服务器控件在生成html的时候他的ID都是会变的,所以在JS想要获取指定ID的服务器控件可以这样
var lbl=documentgetElementById("<%=Label1ClientID %>");
如果是在datalist里面的话也可以这样,比如你想要Label的值为1的Label
var label;
var lbl=documentgetElementById("<%=DataList1ClientID %>")getElementsByTagName("span");
for(var i=0;i<spanlength;i++)
{
if(lbl[i]innerHTML=="5")
{
label=lbl[i];
}
}
这样就能取到你要的那个label啦!
一、问题阐述根据页面上h:selectOneMenu所选的选项,利用js和css来控制页面上另一组件的显示二、代码1页面代码<html<head<script type="text/javascript"function load(){var selectComp=documentgetElementById("selectComp");ifShowDiv(selectComp);}</script</head<body onload="load()"<h:selectOneMenu id="selectComp" value="#{backbeanifShow}" style="width:280px;" onchange="ifShowDiv(this);"<f:selectItem itemValue="show" itemLabel="show"/<f:selectItem itemValue="dont show" itemLabel="dont show"/</h:selectOneMenu<div id="info"show the info here</div</body</html2js代码方法一 得到label值function ifShowDiv(obj){var selectedLabel=objoptions[objselectedIndex]text;if(selectedLabel=="show"){documentgetElementById("info")styledisplay='';}else{documentgetElementById("info")styledisplay='none';}}方法二 得到value值function ifShowDiv(obj){var selectedbValue=objvalue;if(selectedbValue=="show"){documentgetElementById("info")styledisplay='';}else{documentgetElementById("info")styledisplay='none';}}三、注意1在select的value值不确定的情况下,方法一可以直接得到所选中的label值。
<html>
<head>
<title>对象</title>
</head>
<body>
<input type="radio" name="money" value="1"><label id="label_1">1-10 岁</label>
<input type="radio" name="money" value="2"><label id="label_2">11 岁</label>
<input type="radio" name="money" value="3"><label id="label_3">12-120 岁</label>
<input type="button" onclick="getRadioValue()" value="测试选择值">
</body>
<script type="text/javascript">
function getRadioValue(){
var zoneNames=documentgetElementsByName("money");
var myvalue="";
for(var i=0;i<zoneNameslength;i++){
var zoneName=zoneNames[i];
if(zoneNamechecked){
myvalue=zoneNamevalue;
alert(documentgetElementById("label_"+myvalue)innerHTML );
}
}
}
</script>
</html>
以上就是关于求大神解答如何用VB获取某个网页的<label></label>和<td></td>标签中的值,放在文本框中全部的内容,包括:求大神解答如何用VB获取某个网页的<label></label>和<td></td>标签中的值,放在文本框中、.net如何单机按钮的时候获取label和text的内容显示到表格中、JS 怎么获取后台动态创建Label的值!!等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)