87,992
社区成员
发帖
与我相关
我的任务
分享
<div id="d_spell">
<input id="spell" title="" name="spell" class="input wide" type="text" validateurl="{config.webpath}tools/submit_ajax.ashx?action=validate_username"/>
</div>
<script type="text/javascript" src="{config.templateskin}/js/jquery-webox.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#inside').click(function () {
$.webox({
height: 188,
width: 400,
bgvisibel: true,
title: '内嵌弹出层调用',
html: $("#pingxie").html()
});
});
$("#spell").keyup(function () {
var aaa = $("#spell").attr("title");
var bbb = $("#spell").attr("value");
if (aaa == bbb) {
alert("相同");
}
else {
alert("不同");
}
});
})
</script>
</head>
<body>
<a href="javascript:void(0);" id="inside" ><strong>单词拼写</strong></a>
<div id="pingxie" style="display:none;">
<div>
<input id="spell" title="123" name="spell" class="input wide" type="text" />
</div>
</div>
</body>
将你的input标签的id换成class,
$('#inside').click(function () {
$.webox({
height: 188,
width: 400,
bgvisibel: true,
title: '内嵌弹出层调用',
html: $("#pingxie").html()
});
});这个调用里面的html后面改为:$("#pingxie").clone();
这个键盘事件#改为.就可以了
$("#spell").keyup(function () {
var aaa = $("#spell").attr("title");
var bbb = $("#spell").attr("value");
if (aaa == bbb) {
alert("相同");
}
else {
alert("不同");
}
}); function upperCase() {
var aaa = $("#spell").attr("title");
var bbb = $("#spell").val();
if (aaa == bbb) {
alert("相同");
}
else {
alert("不同");
}
}<a href="javascript:void(0);" id="inside" ><strong>单词拼写</strong></a>
<div id="pingxie" style="display:none;">
<div>
<input id="spell" title="123" name="spell" class="input wide" type="text" onkeyup="upperCase()"/>
<div id="aaa"></div>
</div>
</div>


$('body').append('<div class="background" style="display:none;"></div><div class="webox" style="width:' + width + 'px;height:' + height + 'px;display:none;"><div id="inside" style="height:' + height + 'px;"><h1 id="locked" onselectstart="return false;">' + (option['title'] ? option['title'] : 'webox') + '<a class="span" href="javascript:void(0);"></a></h1>' + (option['iframe'] ? '<iframe class="w_iframe" src="' + option['iframe'] + '" frameborder="0" width="100%" scrolling="yes" style="border:none;overflow-x:hidden;height:' + parseInt(height - 30) + 'px;"></iframe>' : option['html'] ? option['html'] : '') + '</div></div>');
$("#spell").bind("keyup", function () {
var aaa = $("#spell").attr("title");
var bbb = $("#spell").attr("value");
if (aaa == bbb) {
alert("相同");
}
else {
alert("不同");
}
});
这样也不对<script type="text/javascript" src="{config.templateskin}/js/jquery-webox.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#inside').click(function () {
$.webox({
height: 188,
width: 400,
bgvisibel: true,
title: '内嵌弹出层调用',
html: $("#pingxie").html()
});
});
$("#spell").keyup(function () {
var aaa = $("#spell").attr("title");
var bbb = $("#spell").attr("value");
if (aaa == bbb) {
alert("相同");
}
else {
alert("不同");
}
});
})
</script>
</head>
<body>
<a href="javascript:void(0);" id="inside" ><strong>单词拼写</strong></a>
<div id="pingxie" style="display:none;">
<div>
<input id="spell" title="123" name="spell" class="input wide" type="text" />
</div>
</div>
</body>
jquery-webox.js 代码
$.extend({
webox:function(option){
var _x,_y,m,allscreen=false;
if(!option){
alert('options can\'t be empty');
return;
};
if(!option['html']&&!option['iframe']){
alert('html attribute and iframe attribute can\'t be both empty');
return;
};
option['parent']='webox';
option['locked']='locked';
$(document).ready(function(e){
$('.webox').remove();
$('.background').remove();
var width=option['width']?option['width']:400;
var height=option['height']?option['height']:240;
$('body').append('<script type="text/javascript" src="/templates/green/js/base.js"></script>');
$('body').append('<div class="background" style="display:none;"></div><div class="webox" style="width:'+width+'px;height:'+height+'px;display:none;"><div id="inside" style="height:'+height+'px;"><h1 id="locked" onselectstart="return false;">'+(option['title']?option['title']:'webox')+'<a class="span" href="javascript:void(0);"></a></h1>'+(option['iframe']?'<iframe class="w_iframe" src="'+option['iframe']+'" frameborder="0" width="100%" scrolling="yes" style="border:none;overflow-x:hidden;height:'+parseInt(height-30)+'px;"></iframe>':option['html']?option['html']:'')+'</div></div>');
if(navigator.userAgent.indexOf('MSIE 7')>0||navigator.userAgent.indexOf('MSIE 8')>0){
$('.webox').css({'filter':'progid:DXImageTransform.Microsoft.gradient(startColorstr=#55000000,endColorstr=#55000000)'});
}if(option['bgvisibel']){
$('.background').fadeTo('slow',0.3);
};
$('.webox').css({display:'block'});
$('#'+option['locked']+' .span').click(function(){
$('.webox').css({display:'none'});
$('.background').css({display:'none'});
});
var marginLeft=parseInt(width/2);
var marginTop=parseInt(height/2);
var winWidth=parseInt($(window).width()/2);
var winHeight=parseInt($(window).height()/2.2);
var left=winWidth-marginLeft;
var top=winHeight-marginTop;
$('.webox').css({left:left,top:top});
$('#'+option['locked']).mousedown(function(e){
if(e.which){
m=true;
_x=e.pageX-parseInt($('.webox').css('left'));
_y=e.pageY-parseInt($('.webox').css('top'));
}
}).dblclick(function(){
if(allscreen){
$('.webox').css({height:height,width:width});
$('#inside').height(height);
$('.w_iframe').height(height-30);
$('.webox').css({left:left,top:top});
allscreen = false;
}else{
allscreen=true;
var screenHeight = $(window).height();
var screenWidth = $(window).width();$
('.webox').css({'width':screenWidth-18,'height':screenHeight-18,'top':'0px','left':'0px'});
$('#inside').height(screenHeight-20);
$('.w_iframe').height(screenHeight-50);
}
});
}).mousemove(function(e){
if(m && !allscreen){
var x=e.pageX-_x;
var y=e.pageY-_y;
$('.webox').css({left:x});
$('.webox').css({top:y});
}
}).mouseup(function(){
m=false;
});
$(window).resize(function(){
if(allscreen){
var screenHeight = $(window).height();
var screenWidth = $(window).width();
$('.webox').css({'width':screenWidth-18,'height':screenHeight-18,'top':'0px','left':'0px'});
$('#inside').height(screenHeight-20);
$('.w_iframe').height(screenHeight-50);
}
});
}
});
我弹出的DIV也是在同一个页面里啊 为什么没有办法调用keyup方法呢? 调试根本就没执行keyup方法 是不是html: $("#pingxie").html()写的有问题呢。大家帮我看看吧[/quote]
在19行后面加上keyup事件看看[/quote]
具体要怎么加 我初学jquery不是很懂你的意思 我17行不是已经加了keyup事件了吗?只要不是弹出层就不会有问题[/quote]
加在这个文件里jquery-webox.js
$('body').append()源文件里在这加了一大段html代码 应该就是弹出层的html
你把事件绑定放到这里试下看看 我也不知道对不对<script type="text/javascript" src="{config.templateskin}/js/jquery-webox.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#inside').click(function () {
$.webox({
height: 188,
width: 400,
bgvisibel: true,
title: '内嵌弹出层调用',
html: $("#pingxie").html()
});
});
$("#spell").keyup(function () {
var aaa = $("#spell").attr("title");
var bbb = $("#spell").attr("value");
if (aaa == bbb) {
alert("相同");
}
else {
alert("不同");
}
});
})
</script>
</head>
<body>
<a href="javascript:void(0);" id="inside" ><strong>单词拼写</strong></a>
<div id="pingxie" style="display:none;">
<div>
<input id="spell" title="123" name="spell" class="input wide" type="text" />
</div>
</div>
</body>
jquery-webox.js 代码
$.extend({
webox:function(option){
var _x,_y,m,allscreen=false;
if(!option){
alert('options can\'t be empty');
return;
};
if(!option['html']&&!option['iframe']){
alert('html attribute and iframe attribute can\'t be both empty');
return;
};
option['parent']='webox';
option['locked']='locked';
$(document).ready(function(e){
$('.webox').remove();
$('.background').remove();
var width=option['width']?option['width']:400;
var height=option['height']?option['height']:240;
$('body').append('<script type="text/javascript" src="/templates/green/js/base.js"></script>');
$('body').append('<div class="background" style="display:none;"></div><div class="webox" style="width:'+width+'px;height:'+height+'px;display:none;"><div id="inside" style="height:'+height+'px;"><h1 id="locked" onselectstart="return false;">'+(option['title']?option['title']:'webox')+'<a class="span" href="javascript:void(0);"></a></h1>'+(option['iframe']?'<iframe class="w_iframe" src="'+option['iframe']+'" frameborder="0" width="100%" scrolling="yes" style="border:none;overflow-x:hidden;height:'+parseInt(height-30)+'px;"></iframe>':option['html']?option['html']:'')+'</div></div>');
if(navigator.userAgent.indexOf('MSIE 7')>0||navigator.userAgent.indexOf('MSIE 8')>0){
$('.webox').css({'filter':'progid:DXImageTransform.Microsoft.gradient(startColorstr=#55000000,endColorstr=#55000000)'});
}if(option['bgvisibel']){
$('.background').fadeTo('slow',0.3);
};
$('.webox').css({display:'block'});
$('#'+option['locked']+' .span').click(function(){
$('.webox').css({display:'none'});
$('.background').css({display:'none'});
});
var marginLeft=parseInt(width/2);
var marginTop=parseInt(height/2);
var winWidth=parseInt($(window).width()/2);
var winHeight=parseInt($(window).height()/2.2);
var left=winWidth-marginLeft;
var top=winHeight-marginTop;
$('.webox').css({left:left,top:top});
$('#'+option['locked']).mousedown(function(e){
if(e.which){
m=true;
_x=e.pageX-parseInt($('.webox').css('left'));
_y=e.pageY-parseInt($('.webox').css('top'));
}
}).dblclick(function(){
if(allscreen){
$('.webox').css({height:height,width:width});
$('#inside').height(height);
$('.w_iframe').height(height-30);
$('.webox').css({left:left,top:top});
allscreen = false;
}else{
allscreen=true;
var screenHeight = $(window).height();
var screenWidth = $(window).width();$
('.webox').css({'width':screenWidth-18,'height':screenHeight-18,'top':'0px','left':'0px'});
$('#inside').height(screenHeight-20);
$('.w_iframe').height(screenHeight-50);
}
});
}).mousemove(function(e){
if(m && !allscreen){
var x=e.pageX-_x;
var y=e.pageY-_y;
$('.webox').css({left:x});
$('.webox').css({top:y});
}
}).mouseup(function(){
m=false;
});
$(window).resize(function(){
if(allscreen){
var screenHeight = $(window).height();
var screenWidth = $(window).width();
$('.webox').css({'width':screenWidth-18,'height':screenHeight-18,'top':'0px','left':'0px'});
$('#inside').height(screenHeight-20);
$('.w_iframe').height(screenHeight-50);
}
});
}
});
我弹出的DIV也是在同一个页面里啊 为什么没有办法调用keyup方法呢? 调试根本就没执行keyup方法 是不是html: $("#pingxie").html()写的有问题呢。大家帮我看看吧[/quote]
在19行后面加上keyup事件看看[/quote]
具体要怎么加 我初学jquery不是很懂你的意思 我17行不是已经加了keyup事件了吗?只要不是弹出层就不会有问题<script type="text/javascript" src="{config.templateskin}/js/jquery-webox.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#inside').click(function () {
$.webox({
height: 188,
width: 400,
bgvisibel: true,
title: '内嵌弹出层调用',
html: $("#pingxie").html()
});
});
$("#spell").keyup(function () {
var aaa = $("#spell").attr("title");
var bbb = $("#spell").attr("value");
if (aaa == bbb) {
alert("相同");
}
else {
alert("不同");
}
});
})
</script>
</head>
<body>
<a href="javascript:void(0);" id="inside" ><strong>单词拼写</strong></a>
<div id="pingxie" style="display:none;">
<div>
<input id="spell" title="123" name="spell" class="input wide" type="text" />
</div>
</div>
</body>
jquery-webox.js 代码
$.extend({
webox:function(option){
var _x,_y,m,allscreen=false;
if(!option){
alert('options can\'t be empty');
return;
};
if(!option['html']&&!option['iframe']){
alert('html attribute and iframe attribute can\'t be both empty');
return;
};
option['parent']='webox';
option['locked']='locked';
$(document).ready(function(e){
$('.webox').remove();
$('.background').remove();
var width=option['width']?option['width']:400;
var height=option['height']?option['height']:240;
$('body').append('<script type="text/javascript" src="/templates/green/js/base.js"></script>');
$('body').append('<div class="background" style="display:none;"></div><div class="webox" style="width:'+width+'px;height:'+height+'px;display:none;"><div id="inside" style="height:'+height+'px;"><h1 id="locked" onselectstart="return false;">'+(option['title']?option['title']:'webox')+'<a class="span" href="javascript:void(0);"></a></h1>'+(option['iframe']?'<iframe class="w_iframe" src="'+option['iframe']+'" frameborder="0" width="100%" scrolling="yes" style="border:none;overflow-x:hidden;height:'+parseInt(height-30)+'px;"></iframe>':option['html']?option['html']:'')+'</div></div>');
if(navigator.userAgent.indexOf('MSIE 7')>0||navigator.userAgent.indexOf('MSIE 8')>0){
$('.webox').css({'filter':'progid:DXImageTransform.Microsoft.gradient(startColorstr=#55000000,endColorstr=#55000000)'});
}if(option['bgvisibel']){
$('.background').fadeTo('slow',0.3);
};
$('.webox').css({display:'block'});
$('#'+option['locked']+' .span').click(function(){
$('.webox').css({display:'none'});
$('.background').css({display:'none'});
});
var marginLeft=parseInt(width/2);
var marginTop=parseInt(height/2);
var winWidth=parseInt($(window).width()/2);
var winHeight=parseInt($(window).height()/2.2);
var left=winWidth-marginLeft;
var top=winHeight-marginTop;
$('.webox').css({left:left,top:top});
$('#'+option['locked']).mousedown(function(e){
if(e.which){
m=true;
_x=e.pageX-parseInt($('.webox').css('left'));
_y=e.pageY-parseInt($('.webox').css('top'));
}
}).dblclick(function(){
if(allscreen){
$('.webox').css({height:height,width:width});
$('#inside').height(height);
$('.w_iframe').height(height-30);
$('.webox').css({left:left,top:top});
allscreen = false;
}else{
allscreen=true;
var screenHeight = $(window).height();
var screenWidth = $(window).width();$
('.webox').css({'width':screenWidth-18,'height':screenHeight-18,'top':'0px','left':'0px'});
$('#inside').height(screenHeight-20);
$('.w_iframe').height(screenHeight-50);
}
});
}).mousemove(function(e){
if(m && !allscreen){
var x=e.pageX-_x;
var y=e.pageY-_y;
$('.webox').css({left:x});
$('.webox').css({top:y});
}
}).mouseup(function(){
m=false;
});
$(window).resize(function(){
if(allscreen){
var screenHeight = $(window).height();
var screenWidth = $(window).width();
$('.webox').css({'width':screenWidth-18,'height':screenHeight-18,'top':'0px','left':'0px'});
$('#inside').height(screenHeight-20);
$('.w_iframe').height(screenHeight-50);
}
});
}
});
我弹出的DIV也是在同一个页面里啊 为什么没有办法调用keyup方法呢? 调试根本就没执行keyup方法 是不是html: $("#pingxie").html()写的有问题呢。大家帮我看看吧[/quote]
在19行后面加上keyup事件看看<script type="text/javascript" src="{config.templateskin}/js/jquery-webox.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#inside').click(function () {
$.webox({
height: 188,
width: 400,
bgvisibel: true,
title: '内嵌弹出层调用',
html: $("#pingxie").html()
});
});
$("#spell").keyup(function () {
var aaa = $("#spell").attr("title");
var bbb = $("#spell").attr("value");
if (aaa == bbb) {
alert("相同");
}
else {
alert("不同");
}
});
})
</script>
</head>
<body>
<a href="javascript:void(0);" id="inside" ><strong>单词拼写</strong></a>
<div id="pingxie" style="display:none;">
<div>
<input id="spell" title="123" name="spell" class="input wide" type="text" />
</div>
</div>
</body>
jquery-webox.js 代码
$.extend({
webox:function(option){
var _x,_y,m,allscreen=false;
if(!option){
alert('options can\'t be empty');
return;
};
if(!option['html']&&!option['iframe']){
alert('html attribute and iframe attribute can\'t be both empty');
return;
};
option['parent']='webox';
option['locked']='locked';
$(document).ready(function(e){
$('.webox').remove();
$('.background').remove();
var width=option['width']?option['width']:400;
var height=option['height']?option['height']:240;
$('body').append('<script type="text/javascript" src="/templates/green/js/base.js"></script>');
$('body').append('<div class="background" style="display:none;"></div><div class="webox" style="width:'+width+'px;height:'+height+'px;display:none;"><div id="inside" style="height:'+height+'px;"><h1 id="locked" onselectstart="return false;">'+(option['title']?option['title']:'webox')+'<a class="span" href="javascript:void(0);"></a></h1>'+(option['iframe']?'<iframe class="w_iframe" src="'+option['iframe']+'" frameborder="0" width="100%" scrolling="yes" style="border:none;overflow-x:hidden;height:'+parseInt(height-30)+'px;"></iframe>':option['html']?option['html']:'')+'</div></div>');
if(navigator.userAgent.indexOf('MSIE 7')>0||navigator.userAgent.indexOf('MSIE 8')>0){
$('.webox').css({'filter':'progid:DXImageTransform.Microsoft.gradient(startColorstr=#55000000,endColorstr=#55000000)'});
}if(option['bgvisibel']){
$('.background').fadeTo('slow',0.3);
};
$('.webox').css({display:'block'});
$('#'+option['locked']+' .span').click(function(){
$('.webox').css({display:'none'});
$('.background').css({display:'none'});
});
var marginLeft=parseInt(width/2);
var marginTop=parseInt(height/2);
var winWidth=parseInt($(window).width()/2);
var winHeight=parseInt($(window).height()/2.2);
var left=winWidth-marginLeft;
var top=winHeight-marginTop;
$('.webox').css({left:left,top:top});
$('#'+option['locked']).mousedown(function(e){
if(e.which){
m=true;
_x=e.pageX-parseInt($('.webox').css('left'));
_y=e.pageY-parseInt($('.webox').css('top'));
}
}).dblclick(function(){
if(allscreen){
$('.webox').css({height:height,width:width});
$('#inside').height(height);
$('.w_iframe').height(height-30);
$('.webox').css({left:left,top:top});
allscreen = false;
}else{
allscreen=true;
var screenHeight = $(window).height();
var screenWidth = $(window).width();$
('.webox').css({'width':screenWidth-18,'height':screenHeight-18,'top':'0px','left':'0px'});
$('#inside').height(screenHeight-20);
$('.w_iframe').height(screenHeight-50);
}
});
}).mousemove(function(e){
if(m && !allscreen){
var x=e.pageX-_x;
var y=e.pageY-_y;
$('.webox').css({left:x});
$('.webox').css({top:y});
}
}).mouseup(function(){
m=false;
});
$(window).resize(function(){
if(allscreen){
var screenHeight = $(window).height();
var screenWidth = $(window).width();
$('.webox').css({'width':screenWidth-18,'height':screenHeight-18,'top':'0px','left':'0px'});
$('#inside').height(screenHeight-20);
$('.w_iframe').height(screenHeight-50);
}
});
}
});
我弹出的DIV也是在同一个页面里啊 为什么没有办法调用keyup方法呢? 调试根本就没执行keyup方法 是不是html: $("#pingxie").html()写的有问题呢。大家帮我看看吧<script type="text/javascript">
$(document).ready(function () {
$('#inside').click(function () {
$.webox({
height: 188,
width: 400,
bgvisibel: true,
title: '内嵌弹出层调用',
html: $("#pingxie").html()
});
});
})
function upperCase(obj) {
var aaa = $("#spell").attr("title");
var bbb = obj.value;
if (aaa == bbb) {
$(".div1").text("输入正确");
}
else {
$(".div1").text("错误");
}
}
</script>
</head>
<body>
<a href="javascript:void(0);" id="inside" ><strong>单词拼写</strong></a>
<div id="div2"></div>
<div id="pingxie" style="display:none;">
<div>
<input id="spell" title="123" name="spell" class="input wide" type="text" onkeyup="upperCase(this)"/>
<div class="div1"></div>
</div>
</div>
</body>
</html>

$('#inside').click(function () {
$.webox({
height: 188,
width: 400,
bgvisibel: true,
title: '内嵌弹出层调用',
html: $("#pingxie").html()
});
//将键盘事件放到这里试下
$(".spell").keyup(function(){
//code
})
});

$("#spell").keyup(function () {
var aaa = $("#spell").attr("title");
var bbb = $("#spell").attr("value");
if (aaa == bbb) {
alert("相同");
}
else {
alert("不同");
}
});
<div>
<input id="spell" title="" name="spell" class="input wide" type="text" />
</div>
一点反应都没有 我是用户点击图片我用jquery弹出上面的层 然后用户输入我在对比[/quote]
有效果啊 你在输入框中输入看看 title先设置个值[/quote]
你看看我6楼的代码 点击单词拼写弹出pingxie层 用户在pingxie里的文本框输入值我调用keyup判断 title赋了值也没用 试过了[/quote]
貌似你这个弹出层 是另一个页面了
你把事件绑定的代码放在弹出层里看看[/quote]
不行啊 放在弹出层里连jquery代码都不显示了 $("#spell").keyup(function () {
var aaa = $("#spell").attr("title");
var bbb = $("#spell").attr("value");
if (aaa == bbb) {
alert("相同");
}
else {
alert("不同");
}
});
<div>
<input id="spell" title="" name="spell" class="input wide" type="text" />
</div>
一点反应都没有 我是用户点击图片我用jquery弹出上面的层 然后用户输入我在对比[/quote]
有效果啊 你在输入框中输入看看 title先设置个值[/quote]
你看看我6楼的代码 点击单词拼写弹出pingxie层 用户在pingxie里的文本框输入值我调用keyup判断 title赋了值也没用 试过了[/quote]
貌似你这个弹出层 是另一个页面了
你把事件绑定的代码放在弹出层里看看<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#spell").keyup(function(){
var aaa = $("#spell").attr("title");
var bbb = $("#spell").attr("value");
if (aaa == bbb) {
alert("相同");
}
else {
alert("不同");
}
});
});
</script>
</head>
<body>
Enter your name: <input id="spell" title="123" name="spell" class="input wide" type="text" />
<p>当发生 keydown 和 keyup 事件时,输入域会改变颜色。请试着在其中输入内容。</p>
</body>
</html>
这样子就不会有问题 $("#spell").keyup(function () {
var aaa = $("#spell").attr("title");
var bbb = $("#spell").attr("value");
if (aaa == bbb) {
alert("相同");
}
else {
alert("不同");
}
});
<div>
<input id="spell" title="" name="spell" class="input wide" type="text" />
</div>
一点反应都没有 我是用户点击图片我用jquery弹出上面的层 然后用户输入我在对比[/quote]
有效果啊 你在输入框中输入看看 title先设置个值[/quote]
你看看我6楼的代码 点击单词拼写弹出pingxie层 用户在pingxie里的文本框输入值我调用keyup判断 title赋了值也没用 试过了