Front End Technology Articles - Page 651 of 652

How do I check if an element is hidden in jQuery?

Ricky Barnes
Updated on 12-Jun-2020 12:48:51

265 Views

Using jQuery, you can detect if a specific element in the page is hidden or visible with is(:visible). You can try to run the following code to learn how to check if an element is hidden in jQuery or not −ExampleLive Demo           jQuery Selector                      $(document).ready(function() {          $("#button1").click(function(){            var visible = $('#myElement').is(':visible');                      if(visible) {               alert("input element is visible");                    }            else            {               alert("input element is hidden");            }          });         });                                     Check Visibility    

How to select element with specific class and title attribute using jQuery?

Ricky Barnes
Updated on 13-Feb-2020 07:33:37

2K+ Views

If your element is having a class and title attribute, still you can select it with jQuery. You can try to run the following code to learn how to select element with specific class and 'title' attribute using jQuery.ExampleLive Demo           The Selector Example                          $(document).ready(function() {             $(".big[title='one']").css("background-color", "yellow");          });                                          This is first division of the DOM.                        This is second division of the DOM.              

How to concatenate variable in a string in jQuery?

David Meador
Updated on 13-Feb-2020 07:25:09

7K+ Views

You can easily concatenate variable in a string in jQuery, using the jQuery html() method. Try to run the following code to learn how to use variable in a string with jQuery −ExampleLive Demo     $(function(){       $("a").click(function(){         var id= $(".id").html();         $('.demo').html("Welcome to ");                   });     });               Click me             Qries    

How can we concatenate two strings using jQuery?

David Meador
Updated on 13-Feb-2020 07:22:50

6K+ Views

To concatenate two strings use the + concatenation operator. You can try to run the following code to learn how to concatenate two strings using jQuery −ExampleLive Demo         $(function(){       $("a").click(function(){         var id= $(".id").html();         $('.myclass').html("Hello");                   });     });              Click me            Tutorialspoint    

What are jQuery string methods?

David Meador
Updated on 13-Feb-2020 07:21:52

971 Views

jQuery string methods helps in string manipulation and makes your work easier while using strings. String methods find the length of the string, a string in a string, extract string parts, etc. jQuery is a JavaScript library, so using JavaScript String functions in it is perfectly fine.ExampleYou can try to run the following code to learn how to find the length of a string with string method −Live Demo Finding the number of characters in "Tutorialspoint" Get Length function myFunc() {     var str1 = "Tutorialspoint";     var num = str1.length;     document.getElementById("example").innerHTML = num; }

How to use a variable in a string in jQuery?

Ricky Barnes
Updated on 12-Feb-2020 12:53:46

4K+ Views

jQuery is a JavaScript library introduced to make development with JavaScript easier. Let us see how to use variable in a string using the html() method.ExampleYou can try to run the following code to learn how to use variable in a string in jQuery −Live Demo    $(function(){       $("a").click(function(){         var id= $(".id").html();         $('.myclass').html("Hello");                   });    });           Click me             Learners    

How to write a custom jQuery plugin?

Ricky Barnes
Updated on 12-Jun-2020 09:00:13

329 Views

To create a jQuery plugin, first create a file named jquery-demoplugin.js with the following code. This is our plugin code. Here, demoplugin is the name of our plugin. You can add any name to your custom plugin −(function ( $ ) {    $.fn.demoplugin = function( options ) {       var web = $.extend({          name: 'example'       }, options );       return this.append('Website: ' + web.name + '.com');    }; }( jQuery ));Now, to load it, add to the HTML file, new.html −    $( document ).ready(function() {       $( '#content ).demoplugin();    });

How to use multiple versions of jQuery on the same page?

Amit D
Updated on 12-Jun-2020 08:58:44

5K+ Views

Yes, you can use multiple versions of jQuery on the same page. To avoid any kind of conflict, use the jQuery.noConflict() method. jQuery.noConflict() method allows you to use multiple frameworks, while using jQuery. Other JavaScript frameworks include Ember, Angular, Backbone, etc.The $ sign is used for jQuery, but what if other frameworks also use the same $ sign; this may create issues and conflict. To avoid this, jQuery issued the noConflict() method. The method releases the $ sign to be used my other JavaScript frameworks. Use jQuery with the name, jQuery.With this, you can also use multiple versions of jQuery ... Read More

How do I add a simple jQuery script to WordPress?

Amit D
Updated on 04-Dec-2019 07:01:14

390 Views

WordPress is an open source CMS, used to develop dynamic websites. Let’s learn how to add jQuery script to WordPress. In the WordPress Theme folder, create a folder "js", and add a file in that. That file will be your Query file with extension “.js”. Add your jQuery script to that file. We have named it new.js, Here’s your jQuery script:jQuery(document).ready(function($) {   $('#nav a').last().addClass('last'); });Open your theme's functions.php file. Use the wp_enqueue_script() function so that you can add your script. Here’s the code:add_action( 'wp_enqueue_scripts', 'add_my_script' ); function add_my_script() {    // name your script to attach other scripts and de-register, ... Read More

How to call a jQuery plugin without specifying any elements?

Amit D
Updated on 04-Dec-2019 07:02:17

321 Views

To call a jQuery plugin without specifying any elements, use extend method. Here’s a snippet showing how to call a jQuery plugin without specifying any elements:$.fn.extend({   myFunction1: function(){...} }); $.extend({   myFunction2: function(){...} });Above, you can see we’re calling myFunction1 and myFunction2 without specifying any elements and using jQuery extend.

Advertisements