我有以下HTML代码:
<div id="someId"> <div ng-transclude> </div> </div>真的很简单我使用以下函数获取具有ID属性的div元素:
var getElementById = function (id) { return angular.element("#" + id); };在这个例子中,ID是'someId'。 我的目标是将div放在我刚刚得到的那个里面。 所以我想用ng-transclude属性返回div。 我相信这会通过按属性名称或其他东西获取元素来实现。
提前致谢。
PS:我不能在我想要的div中添加任何其他属性(比如id)因为在现实生活中它更加复杂并且代码是自动生成的。
I have the following HTML code :
<div id="someId"> <div ng-transclude> </div> </div>Really simple I am getting the div element which has ID attribute using the following function :
var getElementById = function (id) { return angular.element("#" + id); };Where in this example case the ID is 'someId'. My goal is to get the div inside the one I just got. So I want to return the div with ng-transclude attribute. I believe that this will happen by getting an element by attribute name or something.
Thanks in advance.
PS: I can't put any other attributes in the div I wanted(like id) because in the real life it is far more complecated and the code is auto-generated.
最满意答案
我想这会对你有所帮助
var getElementByAttribute = function (attribute) { return angular.element(document).find('[' + attribute + ']'); }; var el = getElementByAttribute('ng-transclude')I think this will help you
var getElementByAttribute = function (attribute) { return angular.element(document).find('[' + attribute + ']'); }; var el = getElementByAttribute('ng-transclude')更多推荐
发布评论