我有一个div元素(h3,img,p)里面.我想使用jQuery来检测用户何时悬停在这个div上,然后切换此div中的一个元素类.
我正在使用以下代码:
$('.entry').bind({
mouseover: function() {
$('.readMore').toggleClass('inverted');
},
mouseleave: function() {
$('.readMore').toggleClass('inverted');
}
});
Run Code Online (Sandbox Code Playgroud)
当悬停在仅仅上面时,这可以正常工作div.如果你将鼠标悬停在div中的一个元素上(例如..entry h2)它会关闭类,就好像它已离开父div(.entry)但它实际上在它内部.这些元素没有漂浮在里面div.entry,我原以为可能会把它扔掉.我试过$(".entry *"),$(".entry, .entry *")但这两个都有类似的问题.
有什么想法吗?
快速jQuery选择器问题:
我需要获取包含字符串的第一个元素(div/ span/ ...)的内容class(例如:"price").
不喜欢这样的东西; o):
var price = ( $('[class*=price]').text() );
Run Code Online (Sandbox Code Playgroud)
非常感谢 !!!
如果没有找到结果,我希望自动完成在其下拉列表中显示"无结果".
我的情况就像JQuery的默认示例.
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助.
正如超长标题所暗示的那样,我需要一些jQuery Document Ready等效的东西,它可以处理动态加载的内容,这些内容是通过jQuery Mobile手风琴/可折叠的ajax加载的.
我们有一些事情不会起作用:
$(document).ready() 将无法正常工作,因为从技术上讲,我们正在等待加载的文档.$('div#id').load() 似乎不起作用.$('div#id').ready() 无论是否运行可折叠内容,似乎都会在加载实际页面时随时运行.这是一个在黑暗中的镜头,但你们可以帮助的任何东西,我很感激:).
谢谢
我有几个jQuery UI Dialogs处理程序,所有这些都包含以下内容:
open: function(event, ui) {
$(".ui-dialog-titlebar").removeClass("ui-corner-all");
$(".ui-dialog").removeClass("ui-corner-all");
},
Run Code Online (Sandbox Code Playgroud)
这样对话框就有方角,而不是圆角.我想知道是否可以将此设置为默认值,这样我就不必将此代码插入到页面上的每个对话框配置中.
我知道我可以编辑CSS,但如果不需要,实际删除该类会更有意义.
我有这个代码:
var myList = [ "Avellino", "Enna", "Frosinone" ];
myInput.autocomplete({
source: function(request, response) {
var data = $.grep(myList, function(value) {
return value.substring(0, request.term.length).toLowerCase() == request.term.toLowerCase();
});
response(data);
},
appendTo: "#myDiv"
});
Run Code Online (Sandbox Code Playgroud)
我想,当我点击输入框时,显示所有元素的列表(使用相同的自动完成框选择值)myList.
我想我需要第三部分处理程序,例如:
myInput.focus(function () {
});
Run Code Online (Sandbox Code Playgroud)
但我不知道如何与自动完成对话.任何想法/解决方案?
我有一个页面有多个表单,通过ajax加载.每个表单都包含一个需要自动填充的文本字段.每个文本都有自动完成源的数据属性.例如:
<input type="text" class="district_name" data-autocomplete-source="['foo','bar','baz']" ... />
Run Code Online (Sandbox Code Playgroud)
可能有很多这些,它们将属于不同的形式并修改不同的记录,但自动完成字段将具有相同的类.
如果我这样调用自动完成...
$('input.district_name').autocomplete({
source: $('input.district_name').data('autocomplete-source')
});
Run Code Online (Sandbox Code Playgroud)
...然后jQuery UI将每个字段的源合并到一个主列表中.我试着打电话给...
$('input.district_name').autocomplete({
source: $( this ).data('autocomplete-source')
});
Run Code Online (Sandbox Code Playgroud)
...我希望从自己的父母那里获取资源,但这根本不起作用.因为这些字段是通过ajax添加到页面的,所以我事先并不知道他们的个人ID是什么,只有课程.可能有很多或很少,它只取决于用户在做什么.
你怎么解决这个问题?
好吧,我很难过这个.我需要遍历这些,所以我可以按类别列出类似的东西
商业书籍
书1
书2
书3
烹饪书籍
等等..
但无法弄清楚如何遍历嵌套对象.有或没有jquery是好的
window.books = {
"Business Books": [
{
Title: "Finance 101",
Description: "Info for Finance 101 book goes here."
},
{
Title: "Economics 123",
Description: "Info for Economics 123 book goes here."
},
{
Title: "Statistics for Beginners",
Description: "Learn about Statistics."
}
],
"Cooking Books": [
{
Title: "Lowfat Treats",
Description: "Eat a lowfat Diet"
},
{
Title: "Chocolate Lovers",
Description: "Eat a lot of chocolate"
},
{
Title: "Book of Brownies", …Run Code Online (Sandbox Code Playgroud) 我有以下代码
var results =
repository.GetItemsAsQuery<User>().Where(
user => user.EmailAddress.Equals(emailAddress, StringComparison.CurrentCultureIgnoreCase));
return results.Any();
Run Code Online (Sandbox Code Playgroud)
Repository 只是我对 NHibernate 会话的包装,该方法具有以下签名
public IQueryable<T> GetItemsAsQuery<T>()
{
try
{
CheckHasErrored();
return _connection.Session.Query<T>();
}
catch (Exception ex)
{
HasErrored = true;
throw new DataRepositoryException(string.Format("Error getting collection of items of type '{0}'", typeof(T).Name), "DataRepository.GetItems<>", ex);
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行第一个方法时,我收到错误 NotSupportException - Boolean Equals(System.String, System.StringComparison) with source NHibernate。
这似乎暗示错误来自我试图过滤 NHibernate 查询的 LINQ lambda 表达式
user.EmailAddress.Equals(emailAddress, StringComparison.CurrentCultureIgnoreCase)
Run Code Online (Sandbox Code Playgroud)
我使用 NHibernate Queryable 是否错误?我希望它生成的等效 SQL 是
select * from User where emailAddress = @emailAddress
Run Code Online (Sandbox Code Playgroud)
所以我只得到通过数据网络返回的一行。
我使用的是最新版本的 Automapper (v3.0.0.0-ci1036),当它用二进制数据转换对象时,它使用了大量的内存。(10MB 文件为 200MB)。下面是这样一个“文件”开始转换的例子:
class Program
{
static void Main(string[] args)
{
convertObject();
}
private static void convertObject()
{
var rnd = new Random();
var fileContents = new Byte[1024 * 1024 * 10];
rnd.NextBytes(fileContents);
var attachment = new Attachment { Content = fileContents };
Mapper.CreateMap<Attachment, AttachmentDTO>();
Console.WriteLine("Press enter to convert");
Console.ReadLine();
var dto = Mapper.Map<Attachment, AttachmentDTO>(attachment);
Console.WriteLine(dto.Content.Length + " bytes");
Console.ReadLine();
}
}
public class Attachment
{
public byte[] Content { get; set; }
}
public class AttachmentDTO
{ …Run Code Online (Sandbox Code Playgroud) jquery ×8
jquery-ui ×4
autocomplete ×2
javascript ×2
selector ×2
.net-4.5 ×1
automapper ×1
bind ×1
c# ×1
click ×1
hover ×1
html ×1
iqueryable ×1
memory-leaks ×1
nested ×1
nhibernate ×1
object ×1
toggle ×1