logo

NJP

The Power of jQuery and Service Portal

Import · Mar 16, 2021 · article

Working on Portal is always fun!!!! Have you ever come across a requirement wherein you want to make some changes to widget without cloning it. Here is an example to increase the size of catalog item image on mouse hover in "SC Catalog Item" widget using jQuery and widget dependencies.

1. Create a dependency in "SC Catalog Item" widget named "Image Hover".

image

2. Create a JS include "Image Hover" which will call a UI script "hover" (code for UI script is in point 3).

image

image

3. Now create a UI script named "hover" with below code ( The UI type of script should be All)

testing();

function testing() {

    //$('button[name="submit"]').css('background-color', 'black');
    $('img').mouseover( function() {
    $(this).css("transform", "scale(1.5)");
    });

    $('img').mouseout( function() {
    $(this).css("transform", "scale(1)");
    });

}

4. Final result (The image will zoom out on hover)

image

Go give it a try and post your comments

View original source

https://www.servicenow.com/community/developer-articles/the-power-of-jquery-and-service-portal/ta-p/2308089