我有一个jquery $ .ajax()函数的小问题.
我有一个表单,每次单击单选按钮或从下拉菜单中选择创建一个具有所选值的会话变量.
现在 - 我有一个下拉菜单有4个选项 - 第一个(标签为None)有一个值=""其他有其ID.
我想要发生的是无选项(带空白值)删除会话而其他选项创建一个,但仅当具有此特定选择名称的会话尚不存在时 - 因为所有其他选项都分配了相同的金额 - 它只是表明选择了哪一个.
我不确定这是否有意义 - 但看看代码 - 也许这会让它更清晰:
$("#add_ons select").change(function() {
// get current price of the addons
var order_price_addon = $(".order_price_addon").text();
// get price of the clicked radio button from the rel attribute
var add = $(this).children('option').attr('label');
var name = $(this).attr('name');
var val = $(this).val();
if(val == "") {
var price = parseInt(order_price_addon) - parseInt(add);
removeSession(name);
} else {
if(isSession(name) == 0) {
var price = parseInt(order_price_addon) + …
Run Code Online (Sandbox Code Playgroud) 我正试图在鼠标悬停在div上时禁用窗口鼠标滚动功能 - 这样只启用div滚动 - 当鼠标离开div时 - 再次应用滚动到窗口.div绝对定位.
当鼠标光标在div中时,我看到这个帖子使用jquery来禁用鼠标滚轮功能?但它似乎没有提供任何答案 - 因此我的问题.
我假设它会是这样的(如果只存在这些方法):
$('#container').hover(function() {
$(window).scroll().disable();
$(this).scroll().enable();
}, function() {
$(window).scroll().enable();
});
Run Code Online (Sandbox Code Playgroud) 在JavaScript中是否有一种方法可以获得字符串与正则表达式数组匹配的布尔值?
例子是('if'语句代表我想要实现的目标):
var thisExpressions = [ '/something/', '/something_else/', '/and_something_else/'];
var thisString = 'else';
if (matchInArray(thisString, thisExpressions)) {
}
Run Code Online (Sandbox Code Playgroud) 我知道这听起来可能是一个非常简单的问题,但我正在努力确保提供的字符串是数字/十进制格式,以便稍后使用PHP的number_format()函数.
我该怎么做 - 比如有人在文本字段中键入15:00 - 我应该使用什么正则表达式和php函数从中删除冒号并使其仅返回有效字符.
preg_match()返回数组 - 所以我不能将结果传递给number_format(),除非我implode()它或类似的东西.
非常感谢您的帮助.
在其中创建函数是否正确
$(document).ready(function() {
Run Code Online (Sandbox Code Playgroud)
像这样:
$(document).ready(function() {
function callMe() {
}
});
Run Code Online (Sandbox Code Playgroud)
.ready()
在dom准备好之前不需要调用函数,并且ready()
触发事件内部的事件.
只是澄清一点 - 这里是代码,它将说明问题:
$(function() {
var ind = 0;
// some event is executed and changes the value of the ind
// another event which affects the ind variable
// and another one - after this event we call our function
// there's another event - and we call our function again
Run Code Online (Sandbox Code Playgroud)
我需要调用的函数需要ind
变量的更新值- 我想我可以将其作为参数传递,但是有更好的方法吗?
另外 - 另一个重要的事情是,function()
问题还可以改变ind
变量的值- 例如递增它(ind++ …
是否有一个选项与DomDocument删除第一行:
<?xml version="1.0" encoding="UTF-8"?>
Run Code Online (Sandbox Code Playgroud)
类实例化自动将它添加到输出中,但是可以摆脱它吗?
我很生气 - 也许有人能够帮助我.
我需要在AJAX调用之后将点击重新绑定到链接,但由于某种原因它不想工作.
这是我的代码:
if ($('.active').length > 0) {
$('.active').click(function() {
var elem = $(this);
var url = $(this).attr('href');
$.ajax({
url: url,
dataType: 'html',
success: function(data) {
elem.replaceWith(data);
}
});
$('.active').bind('click'); return false;
});
}
Run Code Online (Sandbox Code Playgroud)
任何的想法?
感谢您的回复 - 我修改了代码,但问题仍然存在:
function makeActive() {
if ($('.active').length > 0) {
$('.active').click(function() {
var elem = $(this);
var url = $(this).attr('href');
$.ajax({
url: url,
dataType: 'html',
success: function(data) {
elem.replaceWith(data);
}
});
$('.active').live('click', makeActive);
return false;
});
}
}
$('.active').live('click', makeActive);
Run Code Online (Sandbox Code Playgroud) 嗨,您好,
是否有任何PHP本机函数根据索引的开头和结尾返回数组中的记录范围?
即:
array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd');
Run Code Online (Sandbox Code Playgroud)
现在我想只返回索引1和3之间的记录(b,c,d).
任何的想法?
我试图弄清楚如何使用$(document).click()方法获取点击的元素:
$(document).click(function() {
if ($(this) !== obj) {
obj2.hide();
}
});
Run Code Online (Sandbox Code Playgroud)
在上面的例子中,obj是对象是下拉菜单 - 如果点击我不希望它做任何事情,但如果点击是在页面的主体或任何其他元素 - 它应该触发hide()方法.
我正在使用HTMLPurifier,即使你拥有:
$config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
Run Code Online (Sandbox Code Playgroud)
它会从链接中删除所有"目标"属性.
知道为什么要这样做吗?
jquery ×5
php ×4
arrays ×2
bind ×1
click ×1
document ×1
domdocument ×1
expression ×1
hide ×1
html ×1
htmlpurifier ×1
javascript ×1
mouseover ×1
regex ×1
scroll ×1