v2.5.2
Giriş yap

jquery element seçme işlemi

memdhaci
298 defa görüntülendi
let numbers = [0, 1 , 2, 3, 4, 5]

function create() {
    numbers.forEach(function(x){
        let testItem = document.createElement('div')
        testItem.classList = 'test-item'
    
        testItem.innerHTML += `
            <div class='test-class1'>
                <div class='test-class2'>
                    <div class='test-class3'>
                        ${x}
                    </div>
                </div>
            </div>
        `;
    })

}

şöyle örnek bi kodum var mesela test-class3 ü seçmek için şöyle bir şey yapıyorum ama bunun daha kolay bir yöntemi olduğunu düşünüyorum yardımcı olur musunuz?

şu şekilde yapıyorum

$(testItem).children('.test-class1').children('.test-class2').children('.test-class3').text()
bilinmez1i
595 gün önce
/*
Merhaba @memdhaci;
Umarım aşağıdaki kodlar yardımcı olabilir sana.
*/


$('.test-item .test-class1 .test-class2 .test-class3').text()


/*
CSS'deki seçicileri kullandığımız için bu şekilde bir seçim yapabilirsin...
*/