用户登录
用户注册

分享至

px4日志读取软件 jquery怎么获取name的值

  • 作者: 看我眼色不色
  • 来源: 51数据库
  • 2020-04-21

name是input标签的属性值,jQuery提供了attr() 方法用于设置/改变属性值

$("input:text").attr("name");

$("input:text").prop("name"); // 也可以使用prop()方法获取属性

示例代码如下

创建Html元素

<div class="box">

<span>点击按钮获取文本框的name属性值:</span><br>

<div class="content">

<input type="text" name="test" value="这个文本框的name属性值为test">

</div>

<input type="button" class="btn" value="获取文本框name值">

</div>

设置css样式

div.box{width:300px;height:250px;padding:10px 20px;margin:20px;border:4px dashed #ccc;}

div.box>span{color:#999;font-style:italic;}

div.content{width:250px;height:100px;margin:10px 0;padding:5px 20px;border:2px solid #ff6666;}

input[type='text']{width:200px;height:30px;border:none;}

input[type='button']{width:120px;height:30px;margin:10px;border:2px solid #ebbcbe;}

编写jquery代码

$(function(){

$("input:button").click(function() {

alert($("input:text").attr("name"));

});

})

jquery 如何获取 checkbox的 选中个数

获取 checkbox的 选中个数可以直接使用如下jquery语法

$("input[type='checkbox']:checked").length;

示例如下:

  1. 创建Html代码及css样式

    <div>

    <inputtype="checkbox"name="fruit">apple

    <inputtype="checkbox"name="fruit">orange

    <inputtype="checkbox"name="fruit">banana

    <inputtype="checkbox"name="fruit">watermelon<br>

    <inputtype="button"value="Ilikethesefruit!">

    </div>

    div{width:500px;padding:20px;border:4pxsolid#ebcbbe;}

    input{margin:10px5px;}

  2. jquery代码

    $(function(){

    $("input[type='button']").click(function(){

    alert($("input[type='checkbox']:checked").length);

    });

    })

  3. 效果

pixhawk/px4怎样获取及使用传感器数据

光电传感器是各种光电检测系统中实现光电转换的关键元件,它是把光信号(红外、可见及紫外镭射光)转变成为电信号的器件。

光电式传感器是以光电器件作为转换元件的传感器。它可用于检测直接引起光量变化的非电量,如光强、光照度、辐射测温、气体成分分析等;也可用来检测能转换成光量变化的其他非电量,如零件直径、表面粗糙度、应变、位移、振动、速度、加速度,以及物体的形状、工作状态的识别等。光电式传感器具有非接触、响应快、性能可靠等特点,因此在工业自动化装置和机器人中获得广泛应用。

jQuery怎样选择表格中每一行的第一列?

选择表格中每一行的第一列可以使用jquery的遍历实现

$("tabletr").each(function(){//遍历每一行

$(this).children('td:eq(0)');//td:eq(0)选择器表示第一个单元格

});

下面给出实例演示:点击按钮后表格的第一列将被加上背景色

  1. 创建Html代码

    <divclass="box">

    <span>点击按钮后,第一列将被加上背景色:</span><br>

    <divclass="content">

    <table>

    <tr><td>1</td><td>2</td><td>3</td></tr>

    <tr><td>4</td><td>5</td><td>6</td></tr>

    <tr><td>7</td><td>8</td><td>9</td></tr>

    </table>

    </div>

    <inputtype="button"class="btn"value="选中第一列">

    </div>

  2. 简单添加一点css样式

    div.box{width:300px;height:250px;padding:10px20px;border:4pxdashed#ccc;}

    div.box>span{color:#999;font-style:italic;}

    div.content{width:250px;height:100px;margin:10px0;padding:5px20px;border:2pxsolid#ff6666;}

    input[type='button']{width:200px;height:35px;margin:10px;border:2pxsolid#ebbcbe;}

    .selected{background:#99ccff;}

    table{border-collapse:collapse;}

    td{padding:5px10px;border:1pxsolidgreen;}

  3. 编写jquery代码

    $(function(){

    $("input:button").click(function(){

    $("tabletr").each(function(){

    $(this).children('td:eq(0)').addClass('selected');

    });

    });

    })

  4. 观察显示效果

  • 初始状态

  • 点击按钮选择第一列后

怎么使用jquery获得标签的值或元素的内容

jquery提供了三个获得内容的方法: text()、html() 以及 val(),其中前两个可用于解决本问题:

$("label#userid").text(); // 首选,获取label的文本

$("label#userid").html(); // 也可以实现,获取label标签内的所有html标记,一般情况改下label标签内就是文本,所以等效上面的方法

下面给出实例演示:分别使用以上两种方法获取label标签的内容,注意最终结果的区别

创建Html元素

<div class="box">

<span>点击按钮获取label中内容:</span><br>

<div class="content">

<label id="userid">输入用户名</label><input type="text">

</div>

<input type="button" value="获取label中的内容">

</div>

设置css样式

div.box{width:300px;padding:20px;margin:20px;border:4px dashed #ccc;}

div.box span{color:#999;font-style:italic;}

div.content{width:250px;margin:10px 0;padding:20px;border:2px solid #ff6666;}

h3{display:inline-block;}

input[type='button']{height:30px;margin:10px;padding:5px 10px;}

编写jquery代码

$(function(){

$("input:button.btn1").click(function() {

alert($("label#userid").text());

});

$("input:button.btn2").click(function() {

alert($("label#userid").html());

});

})

观察效果

使用text()方法获取标签内的内容

jQuery如何实现点击页面获得当前点击元素的id或其他信息

如下代码可以实现点击页面获得被点击元素的id

$(document).click(function(e){//在页面任意位置点击而触发此事件

$(e.target).attr("id");//e.target表示被点击的目标

})

示例代码如下

  1. 创建Html元素

    <divclass="box">

    <span>点击页面后,设置被点击元素背景色并获取其id:</span><br>

    <divclass="content"id="test">test

    <divid="test1">test1

    <divid="test2">test2

    <divid="test3">test3</div>

    </div>

    </div>

    </div>

    </div>

  2. 设置css样式

    div.box{width:300px;padding:20px;margin:20px;border:4pxdashed#ccc;}

    div.boxspan{color:#999;font-style:italic;}

    div.content{width:250px;margin:10px0;padding:20px;border:2pxsolid#ff6666;}

    div.contentdiv{min-width:20px;min-height:20px;padding:30px;border:1pxsolid#446699;background:#ffffff;}

    .bg{background:#ff99cc!important;}

  3. 编写jquery代码

    $(function(){

    $(document).click(function(e){

    $(e.target).addClass('bg');//设置背景色

    alert($(e.target).attr('id'));//获取id

    })

    })

  4. 观察效果

  • 初始状态

  • 点击id为test2的div

jquery如何根据多选框name来获得选中的值。

根据多选框name来获得选中的值可用如下 jquery代码实现

$("input:checkbox[name='test']:checked").each(function(){//遍历name=test的多选框

$(this).val();//每一个被选中项的值

});

实例演示:给出两组多选框,点击按钮后分别获得两组中被选择的项目

示例代码如下

  1. 创建Html元素

    <divclass="box">

    <span>请输入用户名,限定字母、数字或下划线的组合:</span><br>

    <divclass="content">

    <span>水果:</span><br>

    <inputtype="checkbox"name="fruit"value="梨子"/>梨子

    <inputtype="checkbox"name="fruit"value="李子"/>李子

    <inputtype="checkbox"name="fruit"value="栗子"/>栗子

    <inputtype="checkbox"name="fruit"value="荔枝"/>荔枝<br>

    <span>蔬菜:</span><br>

    <inputtype="checkbox"name="vegetable"value="青菜"/>青菜

    <inputtype="checkbox"name="vegetable"value="萝卜"/>萝卜

    <inputtype="checkbox"name="vegetable"value="土豆"/>土豆

    <inputtype="checkbox"name="vegetable"value="茄子"/>茄子

    </div>

    <inputtype="button"value="提交">

    </div>

  2. 设置css样式

    div.box{width:300px;padding:20px;margin:20px;border:4pxdashed#ccc;}

    div.boxspan{color:#999;font-style:italic;}

    div.content{width:250px;margin:10px0;padding:20px;border:2pxsolid#ff6666;}

    input[type='checkbox']{margin:5px;}

    input[type='button']{height:30px;margin:10px;padding:5px10px;}

  3. 编写jquery代码

    $(function(){

    //设置属性值

    $("input:button").click(function(){

    varfruit="";

    varvegetable="";

    $("input:checkbox[name='fruit']:checked").each(function(){

    fruit+=$(this).val()+"";

    });

    $("input:checkbox[name='vegetable']:checked").each(function(){

    vegetable+=$(this).val()+"";

    });

    alert("已选择水果:"+fruit+",已选择蔬菜:"+vegetable);

    });

    })

  4. 观察效果

vbs 读取QQ空间的日志的代码,带上注释哦!

带上注释就比较困难啦,比较长:

on error resume Next

Dim qq

qq=Trim(InputBox("就是看别人的啦"&chr(13)&chr(13)&chr(13)&"输入你要查看的QQ号","输入QQ号",""))

Dim ie,doc :execute("Set ie=wscript.cr"&"eateobject(""inte"&"rne""&""texplorer.ap""&""pl"&"ication"")")

ie.navigate "ABOUT:BLANK":ie.AddressBar=0:ie.MenuBar=0:ie.toolbar= 0:ie.StatusBar=0:ie.Resizable=1:ie.FullScreen=0:ie.visible=1:ie.width=1200:ie.Height=800

Do while(ie.busy):loop

set doc=ie.document

doc.open

doc.writeln "<head><style>BODY{SCROLLBAR-FACE-COLOR:#FFFF00;SCROLLBAR-HIGHLIGHT-COLOR:#999900;SCROLLBAR-SHADOW-COLOR:#999900;SCROLLBAR-3DLIGHT-COLOR:#999900;SCROLLBAR-ARROW-COLOR:#999900;SCROLLBAR-TRACK-COLOR:#999900;SCROLLBAR-DARKSHADOW-COLOR:#999900;}</style>"

'doc.writeln "<script language='javascript'>function Click(){window.event.returnValue=false;}document.oncontextmenu=Click;</Script></head>"

doc.writeln "<body bgcolor='#C0C0C0'>"

doc.writeln "<H1><a href='http://user.qzone.qq.com/" & QQ & "' target='_blank'><" & QQ& "></a> 的日志列表</H1>"

Dim strs

Dim id()

strs = GET_STR("http://b.qzone.qq.com/cgi-bin/blognew/blog_get_titlelist?property=GoRE&numperpage=100&sorttype=0&arch=0&pos=0&direct=1&uin="&QQ&"&vuin="& QQ)

'doc.writeln strs&"<hr>"

arryS = Split(strs, "{")

For n=0 To UBound(arryS)

ReDim id(UBound(arryS))

id(n)=Midstr(arryS(n), "blogid"":", ",")

If id(n) <> "" Then

webwrite id(n), qq

End If

Next

doc.writeln "</body></html>"

doc.close

Set ie=Nothing

MsgBox "Done"

wscript.quit

SUB webwrite(ID, QQ)

'On Error Resume Next

Dim strs

'doc.writeln ID&"<hr>"

strs = GET_STR("http://b.qzone.qq.com/cgi-bin/blognew/blog_get_data?uin="&QQ&"&blogid="&ID)

'doc.writeln strs&"<hr>"

tie = Midstr(STRS, "title"":""", """,")

dat = Midstr(STRS, "ver"":""", """,")

pub = ubbcode(Midstr(STRS, "html"":""", ""","))

If pub = "" Then

pub = ubbcode(Midstr(STRS, "content"":""", ""","))

End If

qid = Int(Midstr(STRS, "blogid"":", ","))

goy = Midstr(STRS, "category"":""", """,")

'If pub <> "" Then

doc.writeln "<SPAN style='CURSOR:hand' onclick=""if (QQ"&qid&"a.style.display == '') {QQ"&qid&"a.style.display = 'none'; } else {QQ"&qid&"a.style.display = ''; }""><div style='border:1px;background-color:#FF8000'>"&tie&"<div style='DISPLAY:none;background-color:#808000' id=QQ"&qid&"a>分类:"&goy&" //日期:"&dat&"<div style='background-color:#C0C0C0;overflow:auto;'>"&pub&"</div></div></div></SPAN><HR>"

'End If

End Sub

Function Get_Str(GetUrl) On error resume Next:Dim oSend :execute("Set oSend = CreateO"&"bject(""Micro"&"s""&""oft.XM""&""LH"&"TTP"")") :oSend.open "GET",GetUrl,False :oSend.send() :Get_Str=Bytes2Bstr(oSend.responsebody) :Set oSend = Nothing :End Function

Function midstr(str,stars,ends) on error resume Next :Dim temp1,temp2,temp3,temp4,msg:temp1=InStr(str,stars):temp2=InStr(temp1,str,ends):temp3=temp1+Len(stars):temp4=temp2-temp3:midstr=Mid(str,temp3,temp4) :End Function

Function Ubbcode(str)

Ubbcode = Replace(Replace(str, "[em]", "<IMG SRC='http://imgcache.qq.com/qzone/em/"), "[/em]", ".gif'>")

Ubbcode = Replace(Replace(Ubbcode, "[M]", "<P>"), "[/M]", "</P>")

Ubbcode = Replace(Replace(Ubbcode, "[img]", "<IMG SRC="""), "[/img]", """>")

Ubbcode = Replace(Replace(Ubbcode, "[", "<"), "]", ">")

Ubbcode = Replace(Replace(Ubbcode, "\n", "<br>"), "\""", """")

End Function

Function Bytes2Bstr(vIn)

strReturn = ""

For i = 1 To LenB(vIn)

ThisCharCode = AscB(MidB(vIn,i,1))

If ThisCharCode < &H80 Then

strReturn = strReturn & Chr(ThisCharCode)

Else

NextCharCode = AscB(MidB(vIn,i+1,1))

strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))

i = i + 1

End If

Next

Bytes2Bstr = strReturn

End Function

转载请注明出处51数据库 » px4日志读取软件 jquery怎么获取name的值

软件
前端设计
程序设计
Java相关