我正在使用'live'函数在表行上执行一些点击操作,即
$("tr").live('click',function() {
alert('Some table row is clicked');
});
Run Code Online (Sandbox Code Playgroud)
我想知道点击和使用哪一行if-else,根据它提供一些自定义警报.谁能告诉我怎么做?
非常感谢.
编辑1:
有没有办法可以引用函数内部单击行的元素?
我想HREF用新的URL 替换列表中的s.
我有这样的事情:
<ul id="sidebarItems">
<li><a href="/PartBasicInfo/XX">Part Basic Info</a></li>
<li><a href="/SupplierContracts/XX">Supplier Contracts</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我正在尝试这个(我知道有很多方法可以做到这一点),但没有任何运气.有任何想法吗?
function SetUrlParams() {
$("#sidebarItems > li > a").each(function (idx, a) {
a.attr("href", "MyURLOfChoice");
});
Run Code Online (Sandbox Code Playgroud) 我有一个系统,每次用户按下"完成"按钮时,会向现有数字x,(..- 40,-20,0,20,40,60 ..)添加20,这会增加x 20,通过Ajax,将这个新值存储在数据库中,并用Ajax实时显示它的变化.
虽然,随着这个数字的增加,我很难找到一种方法来检查它是否满足Javascript的线性方程.
基本上,我想在每次用户增加200点时发出"奖励" ,因为增量是20,我可以肯定它肯定会击中序列,这消除了大于/小于条款的需要.
基本上,我该如何表达:
if x = 200n (if x is 200,400,600,800,1000,1200,1400...) alert("yay");
Run Code Online (Sandbox Code Playgroud)
我真的不明白这是怎么可能的JavaScript还是jQuery?
我想预备http://每个不以它开头的URL,我使用了这个:
if (val.search('http://') === -1) {
val = 'http://' + val;
}
Run Code Online (Sandbox Code Playgroud)
问题是,它附加http://到开始的网址https//
我想忽略这两个http://和https://.
假设我有这个HTML结构:
<div id="Ancestor">
<div>
<div>
....
<div class="DeepChild"></div>
...
<div id="NotAncestor">
<div>
<div>
....
<div class="DeepChild"></div>
Run Code Online (Sandbox Code Playgroud)
我想知道,当我点击DeepChild div时,如果它是Ancestor的后代.
像这样的东西:
$('.DeepChild').click(function () {
if (whichcondition?? === true) { IsFromAncestor = true; }
});
Run Code Online (Sandbox Code Playgroud) 我有一些存储在外部文件中的变量(settings.js):
var company = "Apple";
var city = "Toronto";
var weather = "Sunny";
Run Code Online (Sandbox Code Playgroud)
在我的HTML中,我引用了jQuery和settings.js,其中将存储所有变量.body标签之间的代码如下所示:
<div class="company"></div>
<div class="city"></div>
<div class="weather"></div>
Run Code Online (Sandbox Code Playgroud)
我正在尝试制作一些智能jQuery代码,它将通过settings.js文件读取,查找变量并加载它,然后找到与变量具有相同类名的HTML元素,最后使用变量值更新该元素的内容.
执行函数后,HTML应如下所示:
<div class="company">Apple</div>
<div class="city">Toronto</div>
<div class="weather">Sunny</div>
Run Code Online (Sandbox Code Playgroud)
注意: HTML中可能有多个位置具有相同的类名.所有这些都将在FF本地运行.这是测试/演示项目,所以我不太担心性能.
我的代码:
function removeTds() {
var elements = $('#goldBarList tr:not(:eq(0))').filter(':has(:checkbox:checked):lt(100)');
var count = elements.length;
elements.remove();
if (count === 100)
window.setTimeout(removeTds, 1);
}
removeTds();?
Run Code Online (Sandbox Code Playgroud)
我怎么知道elements变量中的行号?
在placeholder没有出现在IE9浏览器...
提供下面我的代码...做ü需要编写任何IE9的jQuery或CSS破解
<div class="span6">
<i class="bookmarkingContact"></i>
<h3 style="margin-bottom: 22px;">Inquiry</h3>
<input class="span2" type="text" name="email" placeholder="User Name">
<input class="span2" type="text" name="email" placeholder="Company">
<input class="span2" type="text" name="email" placeholder="Email">
<input class="span2" type="text" name="email" placeholder="Password">
<a href="#" style="position: relative; top: 13px;">Sign Up</a>
</div>
Run Code Online (Sandbox Code Playgroud) 我得到这个警告request.GetResponse().GetResponseStream()我该怎么办?
public void GetUserList(string url)
{
var request = (HttpWebRequest) WebRequest.Create(url);
string response;
using (var stream = new StreamReader(request.GetResponse().GetResponseStream()))
{
response = stream.ReadToEnd();
}
response = DelimiterStrings.Aggregate(response, (current, delim) => current.Replace(delim, "\n"));
foreach (var line in response.Split(DelimiterChars))
{
MainWindow.UserList.Add(line);
}
}
Run Code Online (Sandbox Code Playgroud)
Resharper不知道如何"修复它"
我有以下片段的asp.net mvc控制器代码,检查状态是否无效,然后我将更新一个字段的值:
[HttpPost]
public ActionResult Create(ContactInfo contactinfo)
{
if (IsModelStateValid(GetIssues(contactinfo)))
{
db.ContactInfoes.Add(contactinfo);
db.SaveChanges();
return RedirectToAction("Index");
}
contactinfo.Name+="why this is not working".
return View(contactinfo);
}
Run Code Online (Sandbox Code Playgroud)
通过调试我检查了Name字段的新值是否成功传递给了我的View模型,但是在渲染结果中,只更新了字段验证字段,没有渲染字段值更改,有人可以帮助我如何申请这个改变?