小编Nar*_*ana的帖子

jQuery鼠标悬停链接显示隐藏的div

我在extratorrent网站上遇到了mouseover事件,如下图所示.

alt text http://img3.imageshack.us/img3/4516/usercommment999.jpg

当您将鼠标悬停在用户名链接上时,它会显示一个隐藏的div.非常整洁和光滑.

我是jQuery的新手.任何人都可以告诉我如何开始在正确的轨道上做到这一点?谢谢.

更新1:

I wrote something like the following attempting to get the result. The problem is that when I mouse the mouse out the link the Div wont stay, it disappear immediately.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
       <script type="text/javascript">
        $(document).ready(function()
        {


    $("#show_div").mouseover(function() { $("#hello").css('visibility','visible'); });
    $("#show_div").mouseout(function() { $("#hello").css('visibility','hidden'); });


        });
        </script>

    </head>

    <body>

    <a id="show_div" href="#">Link text</a> 
    <div id="hello" …
Run Code Online (Sandbox Code Playgroud)

html jquery sitedesign

13
推荐指数
2
解决办法
5万
查看次数

在String.Format中包含If Else语句

我有以下状态.

  timespan = timespan.FromSeconds(236541)
  formattedTimeSpan = String.Format("{0} hr {1} mm {2} sec", Math.Truncate(timespan.TotalHours), timespan.Minutes, timespan.Seconds)
Run Code Online (Sandbox Code Playgroud)

如果超过一小时,我必须将其格式化为"hrs mn sec".我想在上面的String.Format中检查这个.

谢谢.

c# string string-formatting

8
推荐指数
2
解决办法
1万
查看次数

通过javascript从代码后面访问变量

我有以下代码,我想在javascript中返回变量"t":

代码背后:

Public Shared Function GetSomeText() As String
  Dim result = "This is from code behind"
  Return result
End Function
Run Code Online (Sandbox Code Playgroud)

javascript中的调用者变量:

//This is not working like that, I think
    var t = GetSomeText();
Run Code Online (Sandbox Code Playgroud)

那么,我怎样才能使变量"t"从代码隐藏的函数GetSomeText中获得"结果"?

谢谢.

javascript vb.net asp.net json

7
推荐指数
1
解决办法
3万
查看次数

使用jQuery悬停工具提示的CSS动态位置

我正在编写一个可以容纳HTML标签的简单工具提示.请查看http://jsfiddle.net/Qkwm8/进行演示.

我希望工具提示框能够正确显示,无论元素的位置如何,在这种情况下<a>,显示鼠标悬停事件的工具提示.

工具提示显示正常,除非<a>浮动正确(或位于行的末尾)或屏幕底部未正确显示,它显示在屏幕外

如果<a>浮动正确,或在行的末尾,或位于屏幕的底部,我希望工具提示改变位置,使其保持可见

谢谢.

更新演示链接

这是完整的结果:http://jsfiddle.net/Qkwm8/3/

html javascript css jquery tooltip

6
推荐指数
1
解决办法
1万
查看次数

计算子记录,如果为空,则显示零

我对C#和VB.NET都很好

我有两张桌子.作者和书籍.这是一对多的关系,作者对书籍.我正在写一个查询来显示每个作者有多少本书.

我写了以下查询:

Dim query = From oa In db.Authors _
         Group oa By oa.Book Into grouping = Group _
         Select Author = Book, Count = grouping.Count(Function(s) s.AuthorId)
Run Code Online (Sandbox Code Playgroud)

此查询将给出以下结果:

             - Author A : 2 books
             - Author B : 3 books
             - Author C: 1 book
Run Code Online (Sandbox Code Playgroud)

但是在作者表中,有些作者还没有任何书籍.例如,有两位作者,作者D和作者E还没有书.

我想编写包含所有作者和书籍数量的查询,即使他们还没有任何书籍,但尚未在Books表中记录.

我希望得到像这样的东西:

             - Author A : 2 books
             - Author B : 3 books
             - Author C: 1 book
             - Author D: 0 book
             - Author E: 0 book
Run Code Online (Sandbox Code Playgroud)

谢谢.

c# linq vb.net linq-to-sql

6
推荐指数
1
解决办法
1072
查看次数

jQuery mouseover显示隐藏的div并显示div,如果只有鼠标仍然在div上

我的鼠标悬停和鼠标输出功能有问题.当我鼠标悬停链接时,它显示一个隐藏的<div>,当我鼠标输出div时,它隐藏了div.问题是,如果我将鼠标悬停在链接上,那么我将鼠标移动到不在div上方的其他地方,div将不会消失.

如果我使用链接的mouseout事件来设置div的可见性,那么我将无法将鼠标悬停在div上.

这是我的HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>
            Untitled Document
        </title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js">
        </script>
        <script type="text/javascript">
            $(document).ready(function() {
                $("#show_div").mouseover(function() {
                    $("#hello").css('visibility', 'visible');
                });

                $("#hello").mouseover(function() {
                    $("#hello").css('visibility', 'visible');
                });
                $("#hello").mouseout(function() {
                    $("#hello").css('visibility', 'hidden');
                });
            });
        </script>
    </head>

    <body>
        <br/>
        <br/>
        <br/>
        <br/>
        <a id="show_div" href="#">Link text</a>
        <div id="hello" style="visibility:hidden;">
            <ul>
                <li>
                    Coffee
                </li>
                <li>
                    Tea
                </li>
                <li>
                    Milk
                </li>
            </ul>
        </div>
        <br/>
        <br/>
    </body>    
</html>
Run Code Online (Sandbox Code Playgroud)

html jquery sitedesign

5
推荐指数
1
解决办法
1万
查看次数

在弹出窗口中禁用浏览器的位置栏

我有以下带有Javascript的HTML:

<A HREF="javascript:void(0)"onclick="window.open('http://www.msn.com/','New Windows','height=380, width=300,location=no')">Hide Address Bar</a>
Run Code Online (Sandbox Code Playgroud)

它适用于IE但不适用于FireFox 3及更高版本.

我想在弹出窗口显示时禁用"位置"栏.

html javascript

5
推荐指数
1
解决办法
1万
查看次数

正则表达式大于和小于

此表达式用于检查数字> 1

^ [1-9] + [0-9]*$

  • 什么是检查它是否大于给定值的表达式,比如"99"?
  • 怎么样的值小于99?

更新:

我正在使用ASP.NET验证控件.

谢谢.

regex asp.net

4
推荐指数
1
解决办法
9833
查看次数

使用LINQ查找字符串中的单词

欢迎使用C#或VB.NET建议.

我有以下代码:

 Dim someText = "Stack Over Flow Community"
    Dim someWord = "Over Community"

    If someText.Contains(someWord) Then
        Response.Write("Word found.")
    Else
        Response.Write("No word found.")
    End If


 Function Contains looks only for next words from left to right. 

someText.Contains("Over Stack")  returns False
someText.Contains("Stack Community")  returns False
Run Code Online (Sandbox Code Playgroud)

只要字符串中存在单词,我希望所有这些都返回True.

是否有任何现有的功能覆盖任何情况,无论字符串中的单词位置如何?

c# linq vb.net

4
推荐指数
1
解决办法
3821
查看次数

jQuery优化链接"href"选择

我正在根据"href"文件类型更改"a"标记的类.它工作正常.这是代码:

    $('#divComment a[href$=".pdf"]').removeClass().addClass("pdf");
    $('#divComment a[href$=".doc"]').removeClass().addClass("word");
    $('#divComment a[href$=".docx"]').removeClass().addClass("word");
    $('#divComment a[href$=".zip"]').removeClass().addClass("zip");
    $('#divComment a[href$=".jpg"]').removeClass().addClass("image");
    $('#divComment a[href$=".xls"]').removeClass().addClass("excel");
    $('#divComment a[href$=".xlsx"]').removeClass().addClass("excel");
Run Code Online (Sandbox Code Playgroud)

如何优化此代码?

jquery

4
推荐指数
1
解决办法
196
查看次数