Jquery() Function


jQuery to replace one tag with another

Using jQuery, I'm trying to replace all the occurrences of:
<p>.....</p>

With

<h1>.....</h1>

Code


$('p').replaceWith(function(){
    return $("<h1/>", {html: $(this).html()});
});



Disabling Right Mouse Click

If you are to disable right click on your web browser, you can use the following piece of code:

$(document).ready(function(){
$(document).bind("contextmenu",function(e){
return false;
});
});


Detect Current Mouse Coordinates

Now, suppose you need to detect the current mouse coordinates in the web browser in use. To do this, you can write the following piece of code:


$(document).ready(function() {
$().mousemove(function(e)
{
$('# MouseCoordinates ').html("X Axis Position = " + e.pageX + " and Y Axis Position = " + e.pageY);
});
<div id=MouseCoordinates></div>
});



Set a Timer

The following piece of code can be used to set a timer using jQuery:

$(document).ready(function()
{
window.setTimeout(function()
{
// some code
}, 1000);
});
Jquery() Function Developerinvention 5 of 5
jQuery to replace one tag with another Using jQuery, I'm trying to replace all the occurrences of: <p>.....</p> Wit...

Share this

Related Posts

Previous
Next Post »

Xolo Offer