Friday, September 17, 2010

Jquery Common Operations

1) Get Custom Attribute & Open Popup
this get the custom attribute set to a div opens a popup using that custom attribute as the URL
where the Div is


// Action for when the app icon is clicked
            $(".appIcon").click(function () {
                var url = $(this).attr('takelink');
                window.open(url, '', 'width=800, height=600', '');
            });


2) Change mouse cursor to 'pointer' on rollover of a div
this uses .css (to add a css to the selected div)

//change the pointer
            $(".appIcon").mouseenter(function () {
                $(this).css('cursor', 'pointer');
            });

3) Append all URL links and add Back Link (using .each)

//get all take links
//Updates all a href where the class is .title and append the href url.
$("a.title").each(function() {
            var currHref = $(this).attr("href");
            $(this).attr("href", currHref + "&backURL=" + window.location.pathname);
});

4) Getting Value from TextArea

        $(document).ready(function () {
            $("#lnkSubmit").click(function () {
                /* get the data entered and send it via ajax*/
                var ddata = $("#newsFeedTxt").val();
                alert(ddata);
            });
        });

5) To check if a 'checkbox' is checked

if ($("#myCheckBox").attr('checked') == true)
{
//your action
}



No comments: