为每个div应用CSS样式. [英] Apply css style for each div.

查看:62
本文介绍了为每个div应用CSS样式.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,jQuery和CSS的新成员,在应用样式方面存在问题.下面的代码仅适用于第一个div,我无法显示和隐藏每个div.

Hi, new at jQuery and CSS, have problem with apply style. The code below work only for first div, I cant make show and hide each of div.

<div id="post">
		Some text here
		<span style="float:left"><a href="#">коментувати</a></span>
		<span id="settings"><a href="#">редагувати</a> | <a href="#">видалити</a></span>
		<br /><br />
		<hr>
	</div>
	
	<div id="post" style="">
		Some text here
		<span style="float:left"><a href="#">коментувати</a></span>
		<span id="settings"><a href="#">редагувати</a> | <a href="#">видалити</a></span>
		<br /><br />
		<hr>
	</div>

	<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
	<style>
		#settings {
			float:right; 
			display: none;
		}
	</style>
	<script type="text/javascript">
		$('#post').mouseover(function() {
			
			$('#settings').show();
		}).mouseout(function() {
			$('#settings').css('display', 'none');
		});
	</script>

推荐答案

('#post').mouseover(function(){
('#post').mouseover(function() {


('#settings').show(); }).mouseout(function(){
('#settings').show(); }).mouseout(function() {


('#settings').css('display','none'); }); </script>
('#settings').css('display', 'none'); }); </script>


这篇关于为每个div应用CSS样式.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆