当我将鼠标悬停在按钮图像上时,我有以下代码来提供悬停效果:
$("img.hoverImage")
.mouseover(function () {
var src = $(this).attr("src").match(/[^\.]+/) + "_hover.png";
$(this).attr("src", src);
})
.mouseout(function () {
var src = $(this).attr("src").replace("_hover", "");
$(this).attr("src", src);
});
Run Code Online (Sandbox Code Playgroud)
这非常有效.我现在有一个额外的要求:
我连续三个按钮都有class ="hoverImage".
<a class="imageLink" href=""><img class="hoverImage" src="/Content/Images/1.png"/></a>
<a class="imageLink" href=""><img class="hoverImage" src="/Content/Images/2.png"/></a>
<a class="imageLink" href=""><img class="hoverImage" src="/Content/Images/3.png"/></a>
Run Code Online (Sandbox Code Playgroud)
我仍然希望保持这种悬停效果,但现在我也想改变它,所以当我点击图像时,它会保持显示悬停图像(即使我将鼠标移出该图像).当我点击另一个按钮时,它应该从其他按钮中移除悬停.
注意:单击图像链接不会重定向到新页面(它们只是从js文件中调用一些ajax)
使用jQuery扩展以下代码以支持此功能的最佳方法是什么?看来我需要在单击项目后禁用mouseout处理程序,但我试图避免使用复杂的解决方案.
我有html如下:
<div onclick=" callJavascript()">
<span id="abc"> abc </span>
<span id="def"> def </span>
<span id="ghi"> ghi </span>
</div>
Run Code Online (Sandbox Code Playgroud)
当我点击'abc'或'ghi'时,是否有任何内部function callJavascript(),以找出我点击的跨度ID?
我根本无法理解这里发生了什么.这个问题对我的作业很重要(学习编程所以我是初学者......我的英语也不是那么好,对不起).
我正在尝试读取一个字符串......它可以是一个数字或一定数量的命令.
我只是给出一个很小的例子,说明我正在尝试做什么以及出了什么问题.
def validate():
choice = str(input(">>> "))
if (choice == "exit"):
return 0 # should exit validate
else:
try:
aux = int(choice) # Tries converting to integer
except:
print("Insert integer or exit")
validate() # If it can't convert, prompts me to try again through
# recursivity
else:
return aux
rezult = validate()
print (rezult)
Run Code Online (Sandbox Code Playgroud)
问题是这个小脚本返回完全随机的东西.
如果"退出",则返回"无".
如果第一次输入正确,则返回正确的数字.
如果第一个输入是"错误"而第二个输入是正确的,那么它再次是"无",我根本无法理解出现了什么问题......为什么它不想工作或我应该做什么(或者).
当用户点击"Music On"按钮时,我必须在后台播放ogg音频文件.目前该页面使用AUDIO标签,它可以在Firefox中使用,但不能在IE中使用(由此表确认 ).
有没有真正的跨浏览器方式播放ogg音频文件,如果可能没有Flash?
我知道存在特定的库,如JPlayer或SoundManager,但我真的必须使用其中一个吗?毕竟,只是发出声音......
我想以递归方式检索给定路径中包含的所有文件,目录和子目录.但是当我的代码到达第二级(目录中的目录)时我遇到了问题:它不是打开内部目录来搜索其内容,而是抛出错误.这是我做的:
void getFile(char *path)
{
DIR *dir;
struct dirent *ent;
if ((dir = opendir(path)) != NULL) {
/* print all the files and directories within directory */
while ((ent = readdir(dir)) != NULL) {
if((strcmp(ent->d_name,"..") != 0) && (strcmp(ent->d_name,".") != 0)){
printf ("%s", ent->d_name);
if(ent->d_type == DT_DIR){
printf("/\n");
getFile(ent->d_name);
}
else{
printf("\n");
}
} // end of if condition
} // end of while loop
closedir (dir);
}
Run Code Online (Sandbox Code Playgroud) 我制作了一个将Excel文件读入Dictionary对象的vbs脚本.当我运行脚本时它不会做任何事情.没有错误消息.
这是代码:
Set objWords = CreateObject("Scripting.Dictionary")
objWords.CompareMode = 1
CurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open(CurPath & "/RE Glossary.xls")
Set objWorksheet = objExcel.ActiveWorkBook.WorkSheets("MG")
intRow = 1
Do Until (objExcel.Cells(intRow, 1).Value) = ""
Value1 = (objExcel.Cells(intRow, 1).Value)
Value2 = (objExcel.Cells(intRow, 2).Value)
objWords.item(Value1) = Value2
Loop
objExcel.Quit
msgbox "There are " & objWords.Count & " words in the glossary."
word = inputbox("word")
if objWords.exists(word) then
msgbox word & vbnewline & "------------" & vbnewline & objWords.item(word)
else
msgbox word …Run Code Online (Sandbox Code Playgroud)