Home > Backend Development > PHP Tutorial > js 是否推荐的js如何写(不刷新)

js 是否推荐的js如何写(不刷新)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:55:32
Original
908 people have browsed it

js 是否推荐的js怎么写(不刷新)


当我点击“勾号”时取消推荐,反之叉号时推荐
不要刷新使用js可以实现吗?可以的话js怎么写
------解决方案--------------------

$('img').click(function() {<br />  $(this).attr('src', $(this).attr('src')=='钩号图片url'?'叉号图片url':'钩号图片url');<br />});<br />
Copy after login

------解决方案--------------------
<br /><html><br /><head><br /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br /><title>无标题文档</title><br /></head><br /><body><br /><span>勾</span><br /><span class="err">叉</span><br /><span>勾</span><br /><span class="err">叉</span><br /><span>勾</span><br /><span class="err">叉</span><br /><script><br />//默认class为空时background是勾  class为err 是叉<br />	window.onload = function(){<br />		var span = document.getElementsByTagName('span');<br />		for(var i=0;i<span.length;i++){<br />			span[i].onclick = function(){<br />				if(this.className == ''){<br />					this.className = 'err';<br />					this.innerHTML = '叉';	<br />				}else{<br />					this.className = '';<br />					this.innerHTML = '勾';	<br />				}	<br />			}<br />		}	<br />	}<br /></script><br /></body><br /></html><br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template