Home >Web Front-end >JS Tutorial >Based on jQuery, click to change the URLs of two iframes at the same time_jquery

Based on jQuery, click to change the URLs of two iframes at the same time_jquery

WBOY
WBOYOriginal
2016-05-16 18:24:051119browse

Personally recommend using jQuery to implement it, the code is simple and scalable.
jQuery part:

Copy the code The code is as follows:

function gotourl(url_a, url_b)
{
$('#ifr_a').get(0).src = url_a;
$('#ifr_b').get (0).src = url_b;
}

html call:

Click me and the content of the two iframes below will change


It is also possible to determine the id of the iframe through js, and then assign different src values ​​to different ids, but the code is relatively complicated.


Original text published on Mr.Think’s personal blog: http://mrthink.net/javascript-jquery-twourl-twoifram/
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn