0% found this document useful (0 votes)
18 views

Jquery Methods: //this Is Used To Refer To The Currently Selected Element

This document provides a summary of jQuery methods for selecting elements and setting event methods. It describes how to select elements using $(“selector”) and filter attributes like type and title. It also explains how to set event handlers using .on() to attach functions to events like click and change. The code example shows selecting a checkbox by type and title attributes and running custom code when it changes to add and select an "Abstract" option to a related dropdown.

Uploaded by

busybug491
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Jquery Methods: //this Is Used To Refer To The Currently Selected Element

This document provides a summary of jQuery methods for selecting elements and setting event methods. It describes how to select elements using $(“selector”) and filter attributes like type and title. It also explains how to set event handlers using .on() to attach functions to events like click and change. The code example shows selecting a checkbox by type and title attributes and running custom code when it changes to add and select an "Abstract" option to a related dropdown.

Uploaded by

busybug491
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

jQuery Methods

To select an element.
$(element*filter1+*filter2+ sub-element[filter1][filter2])
Each filter is an attribute value pair. Eg input*type=checkbox+*title=Abstract+

Setting event methods
$(select and elemnt).on(eventName,function(), -);

Event names can be= hover, click, change etc. in function write your custom code.

Understand the following code for reference
$("input[type='checkbox'][title='Abstract']").on('change',function(){
//this is used to refer to the currently selected element
if($(this).prop('checked'))
{
var subType=$("select[title='Submission type']");
var firstOption=$("select[title='Submission type'] option:first").val();
if(!(firstOption==new String('Abstract').valueOf()))
{
// append abstract
subType.prepend("<option value='Abstract'>Abstract</option>");
}
//disabling what is selected
$("select[title='Submission type'] option:selected").prop('selected',false);
//selecting abstract
$("select[title='Submission type'] option:first").prop('selected','selected');

}
});

You might also like