- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用通过 getElementByTagName
从 XML 文件中提取的数据,它返回 HTML Collection Object
但我需要这些数据来发送 REST 请求,所以我需要获取要转换为字符串的 HTML 集合对象。怎么做到的?
这里有更多信息:
com_zimbra_om.prototype._responseHandler=
function(response){
try{
sid = response.xml.getElementsByTagName("session_id");
this.login_user();
}catch(e){
this._showErrorMsg(e);
}
使用此函数,我试图从 REST 响应中获取 session_id
。这里的 sid
(全局变量)是 HTML 集合对象。现在,当我尝试在下一个函数中使用它时:
com_zimbra_om.prototype.login_user = function(){
var url = selected_server + 'services/UserService/loginUser?SID=' +
sid + '&username='+
selected_username +
'&userpass=' +
selected_password;
var request_url = ZmZimletBase.PROXY + AjxStringUtil.urlComponentEncode(url);
所以我在这里使用 sid
作为字符串。
那么我应该如何将 HTML Collection Object 转换成字符串呢?
谢谢
最佳答案
有了这些信息,我只能去
var objectHTMLCollection = document.getElementsByTagName("div"),
string = [].map.call( objectHTMLCollection, function(node){
return node.textContent || node.innerText || "";
}).join("");
关于javascript - 将 [object HTMLCollection] 转换为 javascript 中的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11125825/
有点好奇,因为我知道 HTMLCollections 会自动更新自己,所以我尝试使用 Proxy 观察它们。如下所示 let imagesCollection = document.images; l
// Find all posts var posts = node.getElementsByClassName("userContentWrapper"); var post, text; con
如果我调用document.getElementsByClassName('cl'),我会得到一个 HTMLCollection。它似乎包含 Element 对象而不是 HTMLElement 对象,
rowGetter = i => { const row = this.state.estimateItemList[i]; const selectRevison = this.st
我有一个页面加载由 1000 个元素组成的 HTMLCollection。 我想要实现的是,一旦页面加载,我希望 HTMLCollection 立即被打乱。 (我无法控制如何从服务器接收数据) 我不知
我知道有关于如何访问和迭代 HtmlCollection 的答案,但它在这里对我不起作用: 我得到了一些类为“tabSheetActive”的元素,这些元素的数量可以是 1 或更多。 我通过以下方式访
当我使用 getElementsByClassName 时,我无法访问 HTMLCollection 类型。 我想得到长度但是我不能得到那个 var documentHeader = parent.d
我做了一个网站,需要插入 javascript。我想从我的 HTML 菜单中获取子节点。 这是我的 HTML 结构的一部分:
我发现 HTMLOptionsCollection 对象继承了 HTMLCollection 的属性和方法。 HTMLOptionsCollections->HTMLCollection->Objec
我在这方面遇到了一些困难。在 Backbone 中,我有一个这样的函数: functionOne: function(){ $('#myTExtbox-' + budgetLine.
我有静态 html 存储在 javascript 字符串文字模板中。 单击按钮时(模式弹出窗口),我需要通过函数传递存储的静态 html,并使用存储在隐藏 div 中的动态数据更新其中的元素。 我需要
我试图通过这样做来收集文档中的所有“li”: var first = document.getElementById("scroll-container").getElementsByTagName(
如何在另一个自定义元素的影子 dom 中迭代一个自定义元素的实例? HTMLCollections 似乎没有按预期运行。 (我是一个 jQuerian 和 vanilla js 的新手,所以我确定我在
我是 typescript 的新手,我正在尝试迭代 document.getElementsByClassName() 获取的 HTMLCollection。我的代码是: let tag_list =
我明白HTMLCollection实际上不是一个数组,否则它会被定义为一个数组。我使用一个名为 isArray() 的帮助函数来检测对象是否为数组。我到处都在使用这个小 helper ,在检查 htm
这个问题在这里已经有了答案: Why does jQuery or a DOM method such as getElementById not find the element? (6 个答案)
我正在尝试填充 Element.prototype.children应该返回 HTMLCollection 有一个window.HTMLCollection 不过 var h = new HTMLCo
我有特性搜索功能,可以让我搜索卧室数量、浴室数量、价格(高和低),并且我还试图让它告诉我客户搜索的词是否在记录。比如“河流”之类的。 我一直在使用 .contains() 和 .indexOf(),但
我正在尝试收集此页面上有评级的所有产品的评级:https://www.theluxelens.com/pages/photoshop-overlays 。虽然我可以让下面的代码在我自己的浏览器 (Ch
在 HTML 中我有 9 s 类为“.square”。 我想让它们可点击,我想知道点击了多少次和哪一个并将其存储到数组中。 所以,如果我点击第五个 应点击 5 次[0,0,0,0,0,5,0,0,0
我是一名优秀的程序员,十分优秀!