只选择一个元素.wrapper或.test

时间:2017-01-28 21:29:08

标签: javascript jquery html css

请帮忙,我如何只选择一个元素.wrapper.test

https://jsfiddle.net/nLg96ywe/

enter image description here

我想:

enter image description here enter image description here

非常感谢!

1 个答案:

答案 0 :(得分:2)

我认为您需要使用jquery方法ul并将.stopPropagation()替换为mouseenter,将mouseover替换为mouseleave

mouseout
var ids = ['test','wrapper'];


$.each(ids, function(index, value) {

$('.' + value)
  .mouseover(function(event) {
  event.stopPropagation();
	$(this).css('-webkit-box-shadow', 'inset 0px 0px 0px 4px rgba(255,248,41,1)');
	$(this).css('-moz-box-shadow', 'inset 0px 0px 0px 4px rgba(255,248,41,1)');
	$(this).css('box-shadow', 'inset 0px 0px 0px 4px rgba(255,248,41,1)');
	$(this).css('cursor','pointer');
  })
  .mouseout(function() {
	$(this).css('-webkit-box-shadow', '');
	$(this).css('-moz-box-shadow', '');
	$(this).css('box-shadow', '');
	$(this).css('cursor','default');
  });
  
  });
.wrapper
{
  width:300px;
  height:300px;
  background:#888;
  padding:50px;
}
.test
{
  background:#fff;
}