Some CSS styles need to be applied to an element on hover, and CSS styles have to be applied using javascript/jquery directly and not through stylesheets or $(this).addClass('someStyle')
because I am injecting the DOM elements into another page.
We can apply the usual css styles using
$('#some-content').css({
marginTop: '60px',
display: 'inline-block'
});
How should we add the CSS styles for :hover
events?
Do we have to resort to:
$('#some-content').hover(
function(){ $(this).css('display', 'block') },
function(){ $(this).css('display', 'none') }
)
.hover()
method in jquery. api.jquery.com/hover – Felipe Oriani Dec 4 '12 at 16:15display
attribute randomly, probably not a good example :) – Nyxynyx Dec 4 '12 at 16:18