是否有可能有一个按钮,当点击它将提取特定div标签内的整个代码?在javescript,jquery还是php中有可能吗?
比如说:
<div class="extactMe">
<a href="http://stackoverflow.com"><img src="icon.png"></a>
</div>
如果我点击按钮&#34;提取&#34;例如,在网页上,<div class="extactMe">
到</div>
的整个div标签将被复制到textarea。请指教,谢谢。
答案 0 :(得分:2)
您可以使用URLToReplace = http://www.xf.com/position/?number=1&From=X&To=Y
URLToCrawl = replaceElementXY(URLToReplace, "left", "right")
print URLToCrawl // Display: http://www.xf.com/position/?number=1&From=left&To=right
属性来实现此目的。试试这个:
javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class javax.ws.rs.core.UriBuilder
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:916)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:845)
org.apache.jsp.sprint_002dworkload_jsp._jspService(sprint_002dworkload_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.NoClassDefFoundError: Could not initialize class javax.ws.rs.core.UriBuilder
com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClient.<init>(AsynchronousJiraRestClient.java:45)
com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:37)
com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42)
com.my_org.jira.reports.JiraReport.createRestClient(JiraReport.java:38)
com.my_org.jira.reports.JiraReport.run(JiraReport.java:42)
org.apache.jsp.sprint_002dworkload_jsp._jspService(sprint_002dworkload_jsp.java:98)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
答案 1 :(得分:1)
你试过吗?
var extracted = $('.extractMe').html();
答案 2 :(得分:0)
JSFiddle的完整示例:https://jsfiddle.net/jo37u3xs/
这里不涉及PHP。
Javascript部分:
$(document).ready(function() {
// when you click the button
$("#button-extract").click( function() {
// get the html of the div
var divContent = $('div.extractMe').html();
// insert the html of the div into the textarea
$("textarea#my-textarea").val(divContent);
});
});
HTML:
<div class="extractMe">
<a href="http://stackoverflow.com"><img src="icon.png">Yo, man. The image is missing.</a><br/>
</div>
<br/>
<button type="button" id="button-extract">Extract</button>
<br/><br/>
<textarea cols="50" rows="10" id="my-textarea">
Its empty at the start. Err, not really.
</textarea>
请查看以下jQuery函数以了解它们的作用: