Submit a Form Using jQuery Click Event

Amit D
Updated on 17-Feb-2020 05:53:22

7K+ Views

To submit a form using jQuery click event, you need to detect the submit event. Let’s submit a form using click event and without using click event.ExampleYou can try to run the following code to learn how to submit a form using jQuery click event −Live Demo $(document).ready(function(){     $(function() {    $('#submit1').click(function(e) {         e.preventDefault();         $("#Demo").submit();     });    $('#submit2').click(function(e) {         e.preventDefault();         $("#Demo").submit();     }); }); });     Team             Submit

Make Text Bold, Italic, and Underline Using jQuery

Amit D
Updated on 17-Feb-2020 05:17:22

4K+ Views

To make text bold, italic and underline using jQuery, use the jQuery css() method with the CSS properties font-style, font-weight and text-decoration. You can try to run the following code to learn how to make text bold, italic and underline using jQuery −ExampleLive Demo $(document).ready(function(){     $("p").on({         mouseenter: function(){         $(this).css({"font-style": "italic", "font-weight": "bold","text-decoration": "underline"});         }     });     }); Move the mouse pointer on the text to make text bold, italic and underline.

Change Font Family and Font Size with jQuery

Amit D
Updated on 17-Feb-2020 05:16:10

2K+ Views

To change the font family and font size with jQuery, use the jQuery css() method. The css property font-family and font-size is used. You can try to run the following code to learn how to change font family and font size with jQuery −ExampleLive Demo $(document).ready(function() {    $("p").on({      mouseenter: function() {         $(this).css({"font-family": "Arial, Helvetica, sans-serif", "font-size": "200%"});      }    });     }); Move the mouse pointer on the text to change the font family and size.

Change Text Color with jQuery

Amit D
Updated on 17-Feb-2020 05:13:42

12K+ Views

To change the text color with jQuery, use the jQuery css() method. The color css property is used to change text color.ExampleYou can try to run the following code to learn how to change text color with jQuery −Live Demo $(document).ready(function(){     $("p").on({         mouseenter: function(){             $(this).css("color", "red");         }     });     }); Move the mouse pointer on the text to change the text color.

Return Variable Value from jQuery Event Function

Amit D
Updated on 17-Feb-2020 05:10:34

3K+ Views

You cannot return variable value from jQuery event function. To understand the reason, let us see how data is passed, which was created in the event handler of a button click.ExampleLive Demo $(document).ready(function(){     var a=document.getElementById('demo');     a.addEventListener('click', function(){        var s='Hello World!';        var event = new CustomEvent('build', { 'detail': s });        this.dispatchEvent(event);      })     document.getElementById('parent').addEventListener('build', getData, true);     function getData(e){        alert(e.detail);     } }); Click me

JShell in Java 9

raja
Updated on 17-Feb-2020 05:05:11

240 Views

JShell is a new concept introduced in Java 9 version. It provides Java with REPL (Read-Eval-Print-Loop) ability. By using JShell, we can test the java-based logic and expressions without compiling it. REPL acts as an immediate feedback loop and has a great effect on productivity in that particular language.Step 1: Open Command Prompt and type JShell.Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\Users\User>JShell | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell>Step 2: Type /help (to view JShell commands) in the JShell command window once it starts running.jshell> /help | Type ... Read More

Handle Checkbox Checked State Changed Event in jQuery

Alex Onsman
Updated on 14-Feb-2020 12:48:52

3K+ Views

To handle the checkbox checked state, use the change event. It will check whether the checkox is checked or not.ExampleYou can try to run the following code to learn how to handle when checkbox checked state changed event in jQuery −Live Demo   jQuery Checkbox state     b {     color: red;   }       Check/ Uncheck this checkbox   $( "input" ).change(function() {   var $input = $( this );   $( "p" ).html(     ".attr( \"checked\" ): " + $input.attr( "checked" ) + "" +     ".prop( \"checked\" ): " + $input.prop( "checked" ) + "" +     ".is( \":checked\" ): " + $input.is( ":checked" ) + "" ); }).change();  

Wrap JavaScript Event in a jQuery Event

Alex Onsman
Updated on 14-Feb-2020 12:47:50

296 Views

Yes, you can wrap a JavaScript event in a jQuery event. For wrapping, use the event object. You can try to run the following code to wrap a JavaScript event in a jQuery event −ExampleLive Demo $(document).ready(function(){      $('a.one').click(function(event){         event.preventDefault();      });      function test(event){         $.Event(event).preventDefault();      } });     a.test {       font-weight: bold;     }     body {       font-family:sans-serif;     } Tutorials     QA

Disable Copy Content Function Using jQuery

Alex Onsman
Updated on 14-Feb-2020 12:46:49

2K+ Views

To disable cut, copy and paste of a content in jQuery, use the jQuery bind() function.ExampleYou can try to run the following code to disable copy paste of content using jQuery −Live Demo $(document).ready(function(){   $('#mytext').bind("cut copy paste",function(e) {      e.preventDefault();   }); }); Copy, cut and paste function doesn't work here.

How jQuery Event Namespace Works

Alex Onsman
Updated on 14-Feb-2020 12:44:34

278 Views

The event.namespace property is used to return the custom namespace when the event was triggered.ExampleYou can try to run the following code to learn how event namespace works and how to create and remove namespace −Live Demo $(document).ready(function(){     $("p").on("custom.myNamespace",function(event){         alert(event.namespace);     });     $("p").click(function(event){         $(this).trigger("custom.myNamespace");     });       $("button").click(function(){         $("p").off("custom.myNamespace");     }); });   Click me Click above to generate an alert box. Click the below button to remove namespace, which won’t generate an alert box. Click this button to remove namespace.

Advertisements