jQuery form selectors উদাহরন : জে-কোয়েরী -(পর্ব-২১)

jQuery তে ফর্ম element গুলি সহজে এবং দক্ষতার সাথে select করার জন্য অনেক selector রয়েছে, ক্লায়েন্ট সাইটে কাজ করার জন্য এই ফর্ম element গুলি select করা অত্যান্ত জরুরী। নিম্নে এদের বেশ কিছু তুলে ধরা হল-

1. TextBox – $(‘input:text’)

//To select a textbox
$('input:text');

//To get the textbox value
$('input:text').val();

//To set the textbox value
$('input:text').val("New Text");

2. Password – $(‘input:password’)

//To select a password
$('input:password');

//To get the password value
$('input:password').val();

//To set the password value
$('input:password').val("New Text");

3. Textarea – $(‘textarea’)

//To select a textarea
$('textarea');

//To get the textarea value
$('textarea').val();

//To set the textarea value
$('textarea').val("New Text in Textarea");

4. Radio Buttons – $(‘input:radio’)

//To select a radio button
$('input:radio');

//To get the selected radio button option
$('input:radio[name=radiobutton-name]:checked').val();

//To select the first radio button option
$('input:radio[name=radiobutton-name]:nth(0)').attr('checked',true);
or
$('input:radio[name=radiobutton-name]')[0].checked = true;

5. Check Box – $(‘input:checkbox’)

//To select a checkbox
$('input:checkbox');

//To check whether a checkbox is checked
$('input:checkbox[name=checkboxname]').is(':checked');

//To check a checkbox
$('input:checkbox[name=checkboxname]').attr('checked',true);

//To unchecked a checkbox
$('input:checkbox[name=checkboxname]').attr('checked',false);

6. Upload File – $(‘input:file’)

//To select a file
$('input:file');

//To get the file value
$('input:file').val();

7. Hidden value – $(‘input:hidden’)

//To select a file
$('input:file');

//To get the file value
$('input:file').val();

8. Select(dropdown box) – $(‘select’)

//To select a dropdown box
$('select')
or
$('#dropdown-id')

//To get the selected drop down box value
$('#dropdown-id').val();

//To set the drop down box value to "China"
$("#dropdown-id").val("China");

9. Submit button – $(‘input:submit’)

//To select a submit button
$('input:submit');

10. Reset button – $(‘input:reset’)

//To select a reset button
$('input:reset');

………………………………………………………………………………
আলোকিত একটা সুন্দর সমৃদ্ধ পৃথিবী আমাদের প্রত্যেকেরই স্বপ্ন । আসুন আমাদের মেধা পরিশ্রম কে বিজ্ঞান সম্মতভাবে ব্যবহার করে, আমাদের স্বপ্ন পূরণে অংশ গ্রহণ করি। আজ এখানেই শেষ করলাম। “HAVE A GOOD PROGRAMMING”

জে-কোয়েরী ধারাবাহিক টিউটোরিয়ালঃ

Leave a Comment