jquery articles-juqery-method

Year: 2018

Date: 5-2

json string -> json object

1

JSON.parse();

2

eval()

3

Use the jquery plugin jquery.paraseJSON();

json object -> json string

JSON.stringify()

Date: 5-1


Icons marked in the figure: shortcut key=ctrl+shift+c

Date: 4-30

js:onload

jquery:read

Date: 4-22

The difference between js and jquery

1

Obtain

js:document.getElementBy[id,name,tagName]

jquery:$("")[获取id:$("#id);获取class:$(".class")]

2

event

js:onclick="functionName()",onblur="functionName()"

jquery: $("element").on("operation",function(){})[element:id,class;operation:click,blur,fous] 

3

convert between the two

dom->jquery

After getting the dom object, pass $()

var id =document.getElementById("id");

var $ id = $ (id)

juqery->dom

1

After getting the jquery object, it can be converted by the [index] method

var $id = $("#id);

var id = $ id [0];

2

The ->get method in jquery->

var $id = $("#id);

var id = $id.get(0)

get(0)

Date: 4-21

1

The text()  method sets or returns the text content of the selected element [operating elements: span, p, div]

The val() method returns or sets the value of the selected element [operating element: input]

The html() method returns or sets the content (inner HTML) of the selected element, including tags. / If the method does not set parameters, returns the current content of the selected element

Date: 4-18

1

Check if an element exists in a collection

inArray, method

$.inArray(he,col)

Parameter Description:

ele : Yuan Shu to judge

col: collection

Example of use:


Example description

Equal to -1 Description: does not exist

Not equal to -1 Description: exists

2

Action Label Properties

Add to:

attr

attr('attr','attr_value')

illustrate:

attr: attributes to be added to the tag [value, name, etc.]

attr_value: The attribute value of the added attribute

remove

removeAttr('attr')

illustrate:

attr: attribute name to remove

Date: 4-15

1

Browser Compatibility

open browser -f12


2

Static Website / Standard

[ Hyperlink has jump action , this method avoids hyperlink jump ]

<a  href=”javascript:void(0)”></a>

3 Implement the download function:
3.1
Hyperlink
3.2
href = full path of the file
3.3
Add attribute target="_blank" [optional]
4 Example
<a href="file server address/database storage address" 

target="_blank">下载</a>

4raiao-change value[checkVal]-demo

jsp:
Coupon list display-[In order to highlight the record function, only radio is displayed]
<div id="userCouponList">
<input type="radio" id="{{id}}" checkVal="0" data- type="checkbox" value="{{amount}}" class="pull-right" name="coupons" />
</div>
js
var $userCouponList = $("#userCouponList");
var $coupons = $ userCouponList.find("input[type=radio][name='coupons']");
$coupons.each(function(){
var $this = $(this);
$this.on("click",function( ){
//When it is clicked for the first time, modify the value of radio
if($this.attr("checkVal")=="0"){
       //After clicking, reassign
$this.attr("checkVal", "1");
}else{
                                                       $this.attr("checkVal","0");
}});



});


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325405709&siteId=291194637