JShell in Java 9

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

256 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

314 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

300 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.

jQuery Event for User Pressing Enter in a Textbox

Alex Onsman
Updated on 14-Feb-2020 12:43:26

1K+ Views

The jQuery event for user pressing enter is keyup and keyCode. You can try to run the following code to trigger an event on pressing enter key in textbox,ExampleLive Demo $(document).ready(function(){    $('input').bind("enterKey",function(e){      alert("Enter key pressed");    });    $('input').keyup(function(e){      if(e.keyCode == 13)      {         $(this).trigger("enterKey");      }    }); });   Press Enter key in the above input text.

jQuery Event Helper Methods

Alex Onsman
Updated on 14-Feb-2020 12:42:28

500 Views

jQuery also provides a set of event helper method which can be used either to trigger an event to bind any event types mentioned above.Trigger MethodsThe following is an example which would triggers the blur event on all paragraphs −$("p").blur();Binding MethodsThe following is an example which would bind a click event on all the −$("div").click( function () {    // do something here });Here are some of the jQuery Event Helper methods:S. NoMethod & Description1.blur()Triggers the blur event of each matched element.2.blur( fn )Bind a function to the blur event of each matched element.3.click( )Triggers the click event of ... Read More

Sequence of jQuery Events Triggered

Alex Onsman
Updated on 14-Feb-2020 12:40:26

1K+ Views

The jQuery event handlers always execute in the order they were bound. With jQuery, you can also change the sequence. Let’s see how, for example, fromdemo(1); demo(2);We can change the sequence to −demo(2); demo(1);ExampleYou can try to run the following to learn and change the sequence of jQuery events −Live Demo $(document).ready(function(){     $.fn.bindFirst = function(name, fn) {         this.on(name, fn);         this.each(function() {             var handlers = $._data(this, 'events')[name.split('.')[0]];             var handler = handlers.pop();       ... Read More

Bind jQuery Events on Dynamically Generated Elements

Alex Onsman
Updated on 14-Feb-2020 12:35:23

257 Views

Use the jQuery on() method to bind jQuery events on elements generated through other events. You can try to run the following code to learn how to use on() method to bind jQuery events:ExampleLive Demo $(document).ready(function(){      $(document).on({        mouseenter: function (e) {          alert('mouse enter');        },        mouseleave: function (e) {          alert('mouse leave');       }           }, '.demo'); }); Heading 1 Demo One Demo Two Mouse enter and leave will generate alert boxes.

Suppress jQuery Event Handling Temporarily

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

788 Views

To suppress jQuery event handling temporarily, add a class to your element so that you can prevent further code from execution.ExampleYou can try to run the following code to learn how to suppress jQuery event handling −Live Demo $(document).ready(function(){     $(element).click(function(e) {         e.preventDefault();         // Check for fired class         if ($(this).hasClass('fired') == false) {           // Add fired class           $(element).addClass('fired');           // Remove fired class           $(element).removeClass('fired');           }    }); }); .fired {     font-size: 25px;     color: green; } This is a heading This is a paragraph. This is second paragraph.

Advertisements