There are two textareas, two paragraphs, and one button defined in the following example. The button has apply-border class and has a click event listener attached to it using the click() method. On clicking the button, a border is applied on each of the textarea elements using the css() method. The first parameter being the property to set, which is a border in this case, and the second parameter is the value of this border property.
Moreover, we chain the add() method with css() method to add all paragraphs to this jQuery object. Once again, we use the css()method to set a border for the paragraph elements, using the same procedure as discussed with the textarea elements.
This approach is quite similar to the previous approach but the key distinction is that the method used to attach the event listener to the button is the bind() method with two parameters, the first parameter being the “click“ event and the second parameter being the anonymous function with the same logic as the previous approach, instead of using the click() method.
Please Login to comment...