小编Tam*_*ari的帖子

如何在Javascript中获取属性的值

我有这个输入行,我试图提取值属性的文本:

<input type="text" class="card-input small-font" ng-value="paymentVia.typeDisplay" readonly="" value="Credit card">
Run Code Online (Sandbox Code Playgroud)

该函数getAttribute("class")工作正常,它返回card-input small-font但函数getAttribute("value")返回null.我也尝试了.value但这会返回一个空字符串.

有谁知道为什么会这样?

这是我的JS:

function() {
   var x = document.getElementsByClassName("card-input small-font");
   var payment =x[18].value;

   return payment;
}
Run Code Online (Sandbox Code Playgroud)

javascript getattribute

2
推荐指数
2
解决办法
5万
查看次数

覆盖Visual Basic标签文本

我正在从收发器读取温度值到串口,我希望这个值改变我的Visual Basic窗体中的标签的值.该值每隔几秒就会改变一次.我使用下面的代码:

Me.dataReceived.Text &= [text]
Run Code Online (Sandbox Code Playgroud)

dataReceived是我正在使用的标签,[text]是我从串口读取的数据.这会导致显示数据,但不会覆盖标签,而是将值相互写入.(附加数据).我试图在=之前删除&但是这没有用,因为没有出现.关于我能做什么的任何想法?

我使用的代码如下:

'To receive data into the text field
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived

    While (SerialPort1.IsOpen)
        ReceivedText(SerialPort1.ReadExisting())    'This is called automatically every time  data is received at the Serial Port
    End While

End Sub

Private Sub ReceivedText(ByVal [text] As String)

    Dim temperature As String

    'This function compares the creating Thread's ID with the calling Thread's ID
    If Me.dataReceived.InvokeRequired Then
        Dim x As New SetTextCallback(AddressOf ReceivedText)
        Me.Invoke(x, New Object() …
Run Code Online (Sandbox Code Playgroud)

vb.net label

0
推荐指数
1
解决办法
5527
查看次数

标签 统计

getattribute ×1

javascript ×1

label ×1

vb.net ×1