Tuesday, 18 August 2015

How to find a String that starts/ends with in jQuery

There are several ways to find a String that startswith or endswith the specified value. I have used the regular expression

if (str.match("^Hello")) {
// ...
}

if (str.match("World$")) {
// ...
}

Tuesday, 11 August 2015

How to disable a click event on an element in jQuery/CSS

There are number of ways to bind the click event to an element. We can use off() or unbind() method provided by jQuery remove the click event. We can also do it using CSS

Add the following class to the CSS file. The particular property of the element can be added with this class for certain business conditions.

CSS:

.inactiveLink {
pointer-events: none;
cursor: default;
}

jQuery:

$("a[id=submit]").addClass('inactiveLink');