Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/431.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS-使用jQuery获取当前元素_Javascript_Jquery_Css_Angularjs_Hover - Fatal编程技术网

Javascript AngularJS-使用jQuery获取当前元素

Javascript AngularJS-使用jQuery获取当前元素,javascript,jquery,css,angularjs,hover,Javascript,Jquery,Css,Angularjs,Hover,我有4个模板,每个模板都有鼠标操作: ng-mouseover="enableDragging()" ng-mouseleave="disableDragging()" 在这些函数中,我更改了一些范围变量,希望能够使用jQuery添加一个类。我可以在不传递参数和不更新某些范围变量(或其他解决方法)的情况下执行此操作吗 我的意思是用一种简单的方式使用位于所有4个模板中的类或id,而不命名我在哪个模板上 也许我的想法是错误的故事是: 我想在输入某个div时更改某个范围变量和该div的css,并在离

我有4个模板,每个模板都有鼠标操作:

ng-mouseover="enableDragging()" ng-mouseleave="disableDragging()"
在这些函数中,我更改了一些范围变量,希望能够使用jQuery添加一个类。我可以在不传递参数和不更新某些范围变量(或其他解决方法)的情况下执行此操作吗

我的意思是用一种简单的方式使用位于所有4个模板中的类或id,而不命名我在哪个模板上

也许我的想法是错误的故事是: 我想在输入某个div时更改某个范围变量和该div的css,并在离开该div时回滚该更改


感谢将$event作为参数传递给
ng mouseover
回调函数以获取元素引用

ng-mouseover="enableDragging($event)"
在控制器中

function enableDragging(event){
  var element = event.target;
  console.log(element)
}
如果要根据条件更新Dom节点类,可以尝试使用指令