Arnab Chakraborty

Arnab Chakraborty

29 Articles Published

Articles by Arnab Chakraborty

Page 2 of 3

How do I use jQuery effects?

Arnab Chakraborty
Arnab Chakraborty
Updated on 22-Jun-2020 262 Views

For hiding and showing the div, you can use hide and show method.For hiding$('#id1').hide();For showing$('#id1').show();Example showhide                 $(document).ready(function () {          $('#btn1').click(function () {             $('#id1').hide();          });          $('#btn2').click(function () {             $('#id1').show();          });       });        I Am A Simple Paragraph    Hide    Show MethodDescriptionanimate()Runs a custom animation on the selected elementsclearQueue()Removes all remaining queued functions ...

Read More

How to disable/enable an input box with jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 22-Jun-2020 18K+ Views

We can easily disable input box(textbox,textarea) using disable attribute to “disabled”.$(‘elementname’).attr(‘disabled’,’disabled’);To enable disabled element we need to remove “disabled” attribute from this element.$(‘elementname’).removeAttr(‘disabled’);Example    ed                      $(document).ready(function () {             $('#btn1').click(function () {                $('input').attr('disabled', 'disabled');             });             $('#btn2').click(function () {                $('input').removeAttr('disabled');             });          });              Disable    Enable

Read More

How to check if a div is visible using jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 22-Jun-2020 13K+ Views

You can use .is(‘:visible’) selects all elements that are visible.Example divvisible               $(document).ready(function () {          $("button").click(function () {             var dim = $('#div1').is(":visible");             if (dim == false) {                $('#div1').css({ "display": "block", "color": "red" });             }          });       });     Div is visible    Click Here

Read More

How to get current URL in jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 22-Jun-2020 4K+ Views

For getting the current URL you can use attr() method or window.location.Example url               $(document).ready(function () {          $("button").click(function () {             alert($(location).attr('href'));             alert(window.location);          });       });     Display URL

Read More

How can I get the ID of an DOM element using jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 22-Jun-2020 775 Views

In jQuery attr method is use to get the id attribute of the first matching element.$("btn1").attr("id")In your exampleExample iddom                 $(document).ready(function () {          $('#btn1').click(function () {             alert( $('#test').attr('id'));          });       });                   Click Here

Read More

How to get the content of a textarea using jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 21-Jun-2020 729 Views

Here I am using one textarea and one button.The first textarea is used for user input then click the button and display the value in the alert box.Example Live Demo                    $(document).ready(function () {             $("button").click(function () {                var dim = $("#txt").val();                alert(dim);             });          });     Click Here

Read More

How to count number of rows in a table with jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 21-Jun-2020 1K+ Views

Example Live Demo table        table,th,td {       border:2px solid black;       margin-left:400px;    }    h2 {       margin-left:400px;    }    button {       margin-left:400px;    }            $(document).ready(function () {       $("button").click(function () {          var rowcount = $('table tr').length;          alert("No. Of Rows ::" +rowcount);       });    }); HTML TABLE NAME AGE DD 35 SB 35 AD 5 AA 5 Click Here

Read More

Why we should use whole string in Java regular expression

Arnab Chakraborty
Arnab Chakraborty
Updated on 21-Jun-2020 1K+ Views

In Java regex matches() matches the input string against the whole string as it add a ^ and $ at the end of the input string.so it will not match the substring. So for matching substring, you should use find().Exampleimport java.util.regex.*; class PatternMatchingExample {    public static void main(String args[]) {       String content = "aabbcc";       String string = "aa";       Pattern p = Pattern.compile(string);       Matcher m = p.matcher(content);       System.out.println(" 'aa' Match:"+ m.matches());       System.out.println(" 'aa' Match:"+ m.find());    } }Output'aa' Match:false 'aa' Match:true

Read More

How to match a line not containing a word in Java Regex

Arnab Chakraborty
Arnab Chakraborty
Updated on 21-Jun-2020 520 Views

ExampleLive Demoimport java.util.regex.Matcher; import java.util.regex.Pattern; public class NoRegTest {    public static void main(String[] args) {       String s="^fun";       Pattern pattern = Pattern.compile(s);       Matcher matcher = pattern.matcher("Java is fun");       if(!matcher.find()) {          System.out.println("not found");       }    } }Outputnot found

Read More

How to extract a group from a Java String that contains a Regex pattern

Arnab Chakraborty
Arnab Chakraborty
Updated on 21-Jun-2020 368 Views

How to extract a group from a Java String that contains a Regex patternimport java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexTest {    public static void main(String[] args) {       Pattern pattern = Pattern.compile("fun");       Matcher matcher = pattern.matcher("Java is fun");       // using Matcher find(), group(), start() and end() methods       while (matcher.find()) {          System.out.println("Found the text \"" + matcher.group()             + "\" starting at " + matcher.start()             + " index and ending at index ...

Read More
Showing 11–20 of 29 articles
Advertisements