사용자 도구

사이트 도구


study:jquery

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판이전 판
다음 판
이전 판
study:jquery [2022/02/25 00:18] – [DOM Selector] taekgustudy:jquery [2025/04/15 10:05] (현재) – 바깥 편집 127.0.0.1
줄 1: 줄 1:
 +====== jQuery ======
  
 +[[study:jquery:download|Excel Download]]
 +
 +===== fullCalendar =====
 +[[https://saintsilver.github.io/FullCalendar-Example|FullCalendar-Example Demo]]
 +[[https://github.com/SaintSilver/FullCalendar-Example.git|FullCalendar-Example]]
 +
 +===== Tree Structure =====
 +[[https://github.com/mar10/fancytree/|Fancytree]] - [[study:jquery:fancytree|Fancytree이용하려면]]
 +  * [[https://github.com/mar10/dynatree|Dynatree - old version]]
 +==== DOM ready ====
 +<code javascript>
 +$(document).ready(function(){
 +  console.log("ready!");
 +});
 +//Shorthand for $( document ).ready()
 +$(function(){
 +  console.log("ready!");
 +});
 +</code>
 +
 +==== Avoiding Conflicts with Other Libraries ====
 +<code javascript>
 +var $j = jQuery.noConflict();
 +// $j is now an alias to the jQuery function; creating the new alias is optional.
 +</code>
 +<code javascript>
 +jQuery.noConflict();
 + 
 +jQuery( document ).ready(function( $ ) {
 +    // You can use the locally-scoped $ in here as an alias to jQuery.
 +    $( "div" ).hide();
 +});
 +</code>
 +<code javascript>
 +jQuery.noConflict();
 +(function( $ ) {
 +    // Your jQuery code here, using the $
 +})( jQuery );
 +</code>
 +==== DOM Selector ====
 +<code javascript>
 +// Refining selections.
 +$( "div.foo" ).has( "p" ); // div.foo elements that contain <p> tags
 +$( "h1" ).not( ".bar" ); // h1 elements that don't have a class of bar
 +$( "ul li" ).filter( ".current" ); // unordered list items with class of current
 +$( "ul li" ).first(); // just the first unordered list item
 +$( "ul li" ).eq( 5 );
 +$("#id1, #id2").text();
 +$("#select_id option:selected").text();
 +$("input[id^='boh_ilsu']").each(function(idx,element){})
 +</code>
 +==== Selecting Form Elements ====
 +  * :password
 +  * :reset
 +  * :radio
 +  * :text
 +  * :submit
 +  * :checkbox
 +  * :button
 +  * :image
 +  * :file
 +<code javascript>
 +$( "form :input" );
 +
 +$('input[id$="_ym"]').blur();  // id가 '_ym'으로 끝나는 것을 선택
 +</code>
 +==== Attributes ====
 +<code javascript>
 +// setter
 +$( "a" ).attr( "href", "allMyHrefsAreTheSameNow.html" )
 +$( "a" ).attr({
 +    title: "all titles are the same too!",
 +    href: "somethingNew.html"
 +});
 +// getter
 +$( "a" ).attr( "href" ); // Returns the href for the first a element in the document
 +</code>
 +==== Selecting Elements ====
 +<code javascript>
 +$( "#myId" ); // Note IDs must be unique per page.
 +$( ".myClass" ); // Selecting Elements by Class Name
 +$( "input[name='first_name']" ); // Selecting Elements by Attribute
 +$( "#contents ul.people li" ); // Selecting Elements by Compound CSS Selector
 +$( "div.myClass, ul.people" ); // Selecting Elements with a Comma-separated List of Selectors
 +</code>
 +=== Pseudo-Selectors ===
 +<code javascript>
 +$( "a.external:first" );
 +$( "tr:odd" );
 +
 +// Select all input-like elements in a form (more on this below).
 +$( "#myForm :input" );
 +$( "div:visible" );
 +
 +// All except the first three divs.
 +$( "div:gt(2)" );
 +
 +// All currently animated divs.
 +$( "div:animated" );
 +</code>
 +=== Choosing Selectors ===
 +<code javascript>
 +// Doesn't work!
 +if ( $( "div.foo" ) ) {
 +    ...
 +}
 +</code>