JSLite - HTML code/text/value


If you have any questions, you are welcome to communicate in these places, and you are welcome to join the JSLite.io organization team for joint development!

text

Get the text content of all matching node objects.

$("#box").text() //⇒ string 返回文本
$("#box").text(function(){
    return "这里干点儿什么?"
}) //⇒ string 返回"#box"中的文本

html

Get or set the node object content.

$("#box").html()//⇒ string 返回包括HTML的文本

val

Get the value of the set input.

$("input").val() //⇒ string 
$("input").val("test") //⇒ self 

$("#input").val(function(index,oldvalue){
    console.log(index,oldvalue)
    return "111" + oldvalue
}) //⇒ self

data

Read or write data-* attributes of dom. data(name) ⇒ value data(name, value) ⇒ self

$("#test").eq(0).data("name",{"sss":1}) //⇒ self
$("#test").eq(0).data("name",[1,2,3,4]) //⇒ self 
$("#test").eq(0).data("name") //⇒ [1,2,3,4]  或者 {"sss":1} 对象
$("#test").data({"aa":1,"www":334343}) //⇒ 设置节点属性 data-aa="1" | data-www="334343"
$("#test").data() //⇒  {"aa":1,"www":334343}