Bu selektorni javascriptda qanday olish mumkin?

har bir ro'yxatga bir marta bosish hodisasini qo'llashga harakat qilaman, bu erda ikkinchi kodimning kodi, har bir tanlovchini olishim kerak:

<div class="slick-track">
    
  •  
        
  •  
        
  •  
    </div>
    

    Men bunga harakat qildim:

    $('.slick-track li:nth-child(2) a').click();   
    
    2
    Buni xohlaganingiz uchun $ ('. slick-track> li> a') ni bosing.
    qo'shib qo'ydi muallif Maciej Kozieja, manba
    Faqat $ ('. Slick-track a') yoki $ ('a.magictoolbox-selector') !
    qo'shib qo'ydi muallif ibrahim mahrir, manba
    Faqat $ ('. Slick-track a') yoki $ ('a.magictoolbox-selector') !
    qo'shib qo'ydi muallif ibrahim mahrir, manba

    6 javoblar

    Siz "global" voqealarni yozishingiz mumkin. Uni har bir "a" uchun yozishingiz shart emas.

    $(".slick-track").on("click", "a", function(){
       //your code here
    })
    

    Chertgan elementga kirish uchun: bu da siz chertgan elementingiz bor.

    3
    qo'shib qo'ydi

    Siz "global" voqealarni yozishingiz mumkin. Uni har bir "a" uchun yozishingiz shart emas.

    $(".slick-track").on("click", "a", function(){
       //your code here
    })
    

    Chertgan elementga kirish uchun: bu da siz chertgan elementingiz bor.

    3
    qo'shib qo'ydi

    Mana sizga yordam beradigan umid qilamanki ... ( bu yerda bu erda fiddle ).

    $(document).ready(function(){
       //LISTENER FOR CLICKS ON ANY OF THE LI ELEMENTS...
        $('.slick-track li a').on('click', function(){
               //WHEN CLICKED, SHOW THE TEXT CONTENT FOR THIS ITEM
                    alert($(this).text())
        });
    
     //PERFORM A CLICK ON THE ** SECOND ** LIST ITEM A ELEMENT
        $('.slick-track li:nth-child(2) a').click();  
    })
    
    1
    qo'shib qo'ydi

    Mana sizga yordam beradigan umid qilamanki ... ( bu yerda bu erda fiddle ).

    $(document).ready(function(){
       //LISTENER FOR CLICKS ON ANY OF THE LI ELEMENTS...
        $('.slick-track li a').on('click', function(){
               //WHEN CLICKED, SHOW THE TEXT CONTENT FOR THIS ITEM
                    alert($(this).text())
        });
    
     //PERFORM A CLICK ON THE ** SECOND ** LIST ITEM A ELEMENT
        $('.slick-track li:nth-child(2) a').click();  
    })
    
    1
    qo'shib qo'ydi

    foydalanardim

    $('.slick-track li:nth-child(3) a img').css("background-color", "yellow");
    $('.slick-track li:nth-child(3) a').css("background-color", "yellow");
    $('.slick-track li:nth-child(3)').css("background-color", "yellow");
    

    uning ishi, lekin qachon tugmachani sinab ko'rishsa, hech narsa sodir bo'lmaydi!

    $('.slick-track li:nth-child(3) a img').click();
    $('.slick-track li:nth-child(3) a').click();
    $('.slick-track li:nth-child(3)').click();
    
    1
    qo'shib qo'ydi

    foydalanardim

    $('.slick-track li:nth-child(3) a img').css("background-color", "yellow");
    $('.slick-track li:nth-child(3) a').css("background-color", "yellow");
    $('.slick-track li:nth-child(3)').css("background-color", "yellow");
    

    uning ishi, lekin qachon tugmachani sinab ko'rishsa, hech narsa sodir bo'lmaydi!

    $('.slick-track li:nth-child(3) a img').click();
    $('.slick-track li:nth-child(3) a').click();
    $('.slick-track li:nth-child(3)').click();
    
    1
    qo'shib qo'ydi
    Javascript UZB
    Javascript UZB
    99 ishtirokchilar

    @js_uzb @vuejs_uz @react_uz @nodejs_uz @angular_uz @ngTashkent @yiiframework_uz @laravel_uz @linux_uzbek @python_uz @swift_uzb —————— @uzdevgroup @UzGeeksGroup ——— @UzDev_Jobs @jobs_uzb