ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Can anyone give me an example to use attribute as a selector in jquery?

user-image
تم إضافة السؤال من قبل مستخدم محذوف‎
تاريخ النشر: 2015/10/12
Mostafa Mohammed Naguib
من قبل Mostafa Mohammed Naguib , Senior back-end developer , Egpay payment solution

you can always try something like

$('input[type=text]');

 

which will select all input text boxes

and you can even use the selector as a CSS selector 

input[type=text] {

text-align: right;

}

This selector to give wide range of using the 'data-' attribute as example; you could have a many divs that have same class but some of them share same status

 

<div data-status='opened'>Opened div</div>

<div data-status='closed'>closed div</div>

<div data-status=opened'>Opened div</div>

<div data-status='closed'>closed div</div>

 

so using 

$('div[data-status=closed]');

would select only the closed divs or the open ones

 

hope i could clear that out for you :)

have a great day

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟