Posts

Showing posts with the label jQuery

Problem using $.ajax method of jquery

When we use $.ajax method then sometime we use this in side success method we get unexpected error because in $.ajax method in success property this has different meaning it refers to xmlhttprequest object other then we are expecting. Here is an example and solution for that: Example:     $("#location").change(function () {             if ($(this).val() == "-1") {                 $("#category").prop('disabled', 'disabled');             }                     var that = this;             $.ajax({                 type: "POST",                 url: "/Home/Category",                 data: JSON.stringify({ projectId: $("#project").val(), locationId: $(this).val() }),  ...

CSS property selector using jQuery

We can not directly select element using css property values but to do that we can use filter method of jquery var myDiv = $('div').filter(function () { return this.style.opacity == '0.9' }); This will select all div which has css opacity value 0.9