javascript - Accessing children using children in jQuery -
can 1 me having 2 span on click of 1 span tag p tag should show here html file
<span class="span1" ng-click="show()">span_1 <p class="p1" ng-show="var1">p_1</p> </span> <span class="span1" ng-click="show()">span_2 <p class="p2" ng-show="var1">p_2</p> </span>
and corresponding jquery
var app = angular.module('myapp', []); app.controller('myctrl', function($scope) { $scope.var1 = false; $("span").click(function(){ $(this).children().toggle(); }) });
is there children() tag in angularjs ? plunker http://plnkr.co/edit/unyqby6llrqhab8183nf?p=preview
please have of plunker
<!doctype html> <html> <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <body> <div ng-app="myapp" ng-controller="myctrl"> <span class="span1">span_1 <p class="p1" style="display:none;">p_1</p></span><br> <span class="span1" >span_2 <p class="p2" style="display:none;">p_2</p></span> </div> <script> var app = angular.module('myapp', []); app.controller('myctrl', function($scope) { $("span").click(function(){ console.log($(this).children()) $(this).children().first().toggle(); }) }); </script> </body> </html>
Comments
Post a Comment