I am using gwt. i need give an "remove" image before the label as below.
How i can wrap image before the text and provide hyperlink on an image
?
It can be done using .prepend()
and .append()
:
$('p').prepend(
$('<a></a>', { href : "http://google.com" }).append(
$('<img />', { src : 'http://placehold.it/30x30' })
)
);
In this example I have targeted <p>
elements, so you will obviously need to change the selector according to what element you want to target (e.g table cell, list item?). What this does is first creates an image element and gives it a source, then creates an anchor element with a href, then appends the image to the anchor and finally prepends the anchor to the paragraph elements.