JQUERY Get Element By parameter ID

后端 未结 6 998
执念已碎
执念已碎 2021-01-20 10:31

just want to know what is the equivalent syntax of this to jquery.

var elm_id = \'my_id\';
var elm = document.getElementById(elm_id);

thank

6条回答
  •  被撕碎了的回忆
    2021-01-20 11:18

    In jquery the following code is being written as:

    var elm = $("#my_id");
    

    OR you can write as:

    var elm_id = 'my_id';
    var elm = $("#" + elm_id);
    

提交回复
热议问题