Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 904 Bytes

javascript-jquery.md

File metadata and controls

64 lines (47 loc) · 904 Bytes

javascript / jquery

array

let arr = [];
arr.push(1);
arr.push(2);
arr.slice(arr.indexOf(1)); // remove element 1 (index 0)

locate with jquery

  • search any with some class
let q1 = $('.someclass');
  • search any specific descendant with class that have parent with some class
<table class="sometblclass">
  <tbody>
    <tr>
      <td class="j-mycls"></td>
    </tr>
  </tbody>
</table>
let q1 = $(".sometblclass > tbody > tr > td.j-mycls");
  • search class1 or class2
let q = $(".class1,.class2");
  • search any element with attribute
<button mynfo="xx"></button>
$("button[mynfo]").each((idx,btn) => {
  let mynfo = $(btn).attr("mynfo");
});
  • search with starting
let q = $("[class^='starttext']");
  • search class1 but not class2
let q = $(".class1").not(".class2");