How do I dynamically change the content in an iframe using jquery?

<html> <head> <script type=”text/javascript” src=”https://stackoverflow.com/questions/1554396/jquery.js”></script> <script> $(document).ready(function(){ var locations = [“http://webPage1.com”, “http://webPage2.com”]; var len = locations.length; var iframe = $(‘#frame’); var i = 0; setInterval(function () { iframe.attr(‘src’, locations[++i % len]); }, 30000); }); </script> </head> <body> <iframe id=”frame”></iframe> </body> </html>

jQuery ajax (jsonp) ignores a timeout and doesn’t fire the error event

jQuery 1.5 and higher have better support for error handling with JSONP requests. However, you need to use the $.ajax method instead of $.getJSON. For me, this works: var req = $.ajax({ url : url, dataType : “jsonp”, timeout : 10000 }); req.success(function() { console.log(‘Yes! Success!’); }); req.error(function() { console.log(‘Oh noes!’); }); The timeout seems …

Read more

Using jQuery UI sortable with HTML tables

You can call sortable on a <tbody> instead of on the individual rows. <table> <tbody> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> <tr> <td>5</td> <td>6</td> </tr> </tbody> </table>​ <script> $(‘tbody’).sortable(); </script> $(function() { $( “tbody” ).sortable(); }); table { border-spacing: collapse; border-spacing: 0; } td { width: 50px; height: 25px; border: 1px solid black; …

Read more

replace anchor text with jquery

Try $(“#link1”).text() to access the text inside your element. The # indicates you’re searching by id. You aren’t looking for a child element, so you don’t need children(). Instead you want to access the text inside the element your jQuery function returns.