<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("button").click(function() {
$("h2").html("<p class='test'>click me</p>")
});
$(".test").click(function(){
alert();
});
});
</script>
</head>
<body>
<h2></h2>
<button>generate new element</button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我试图生成类名称的新标签test中<h2>单击按钮.我还定义了一个与之关联的点击事件test.但事件不起作用.
有人可以帮忙吗?
试图写一个可以找到所有模式的正则表达式
p = "q=http://.*\.doc" in
text = "q=http://11111.doc,q=http://22222.doc"
Run Code Online (Sandbox Code Playgroud)
当我在文字上做完时,
我得到了整个事情,即 q=http://11111.doc,q=http://22222.doc
但不是q=http://11111.doc和q=http://22222.doc
我如何解决它?
尝试在其内部引用一个类。例如
class Test:
FOO_DICT = {1 : Test.bar} # NameError: name 'Test' is not defined
@staticmethod
def bar():
pass
Run Code Online (Sandbox Code Playgroud)
这种用法有意义吗?还有更好的选择吗?谢谢!
我打电话给新日期("1月4日"),发现默认年份是2001年
a=new Date("Jan 4")
Thu Jan 04 2001 00:00:00 GMT-0500 (EST)
Run Code Online (Sandbox Code Playgroud)
有什么方法可以将默认年份设置为2011年吗?
更新:我知道我可以使用+ 2011但是因为我有一些"1月4日",而有些"2008年1月4日"我只想使用2011用于前一种情况.
但是,我意识到如果你做Date("2008年1月4日,2011"),那么这一年将是2008年而不是2011年.这正是我所需要的.无论如何,我会将第一个答案标记为正确.
s="12/15"
r=/((0?[1-9])|(1[0-2])){1}\/((0?[1-9])|(1[0-9])|(2[0-9])|(3[0-1])){1}/g
s.match(r)
> ["12/1"]
Run Code Online (Sandbox Code Playgroud)
我试图验证日期格式mm/dd,但匹配的字符串错过了最后一位数字.
有人可以帮忙吗?谢谢,程
在我正在处理的文本文件中,我有像 这样的字符.不确定它们是什么.
我想知道如何删除/转换这些字符.
我试图通过使用.encode('ascii','ignore')将其转换为ascii.python告诉我char不是0,128
我也尝试过unicodedata,unicodedata.normalize('NFKD',text).encode('ascii','ignore'),同样的错误
有人帮吗?
谢谢!
我正在尝试从本地计算机上的远程服务器获取信息.readyState没有问题,即== 4.但是,当我按下按钮时状态总是0(而不是200),它什么也不返回.
这是代码,:
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET",'http://www.spartanbook.com/textbooks_xml.asp?control=campus&campus=45&term=80',true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
它基本上来自w3shcools.只需更换网址.当我将其粘贴到浏览器的地址栏中时,我正在使用的网址正在运行.
任何的想法?谢谢!!
if $programname == "service" then {
if $msg !contains "test" then
action(type="omfwd"
target="10.0.0.5"
...
)
}
Run Code Online (Sandbox Code Playgroud)
我试图排除包含单词 'test' 的消息。不知道如何否定“包含”。
从文档来看,它似乎是“!包含”。尝试过但没有运气。
任何想法?
仅当模式出现在字符串的开头时才替换模式.例如str1 = "abab abadfadsf"
我只想删除/替换str1开头的"ab",即我想编写一个正则表达式,以便我可以str2 = "ab abadfadsf"从str1 获取re.sub
我该怎么做?