代码如下
$(function() {
$.ajax({
type:'POST',
url: 'hhWebsiteInfoController.do?website-getDt',
dataType:'json',
data:'',
success:function(json){
alert(1);
var dts = json.attributes.dts;
$("#news").empty();
if(typeof(dts)!=undefined){
for(var i=0;i
var b = "
var c = a+b;
// var d ="
$("#news").append(c);
}
}}
});
$('#test2').on('click', function() {
// alert(2);
layer.open({
type: 1,
area: ['600px', '360px'],
shadeClose: true, //点击遮罩关闭
content: '
});
});
});
点击id=“test2"的图片没反应,不弹出弹出层,为什么啊??
回复讨论(解决方案)
id不能重复啊
顺便把on绑定事件改成live比较好
id不能重复啊
改完了$.ajax({
type:'POST',
url: 'hhWebsiteInfoController.do?website-getDt',
dataType:'json',
data:'',
success:function(json){
alert(1);
var dts = json.attributes.dts;
$("#news").empty();
if(typeof(dts)!=undefined){
for(var i=0;i
var b = "
var c = a+b;
// var d ="
$("#news").append(c);
}
}}
});
$('.test2').on('click', function() {
// alert(2);
layer.open({
type: 1,
area: ['600px', '360px'],
shadeClose: true, //点击遮罩关闭
content: '
});
});
});
还是不好使哎 - -
id不能重复啊
改完了$.ajax({
type:'POST',
url: 'hhWebsiteInfoController.do?website-getDt',
dataType:'json',
data:'',
success:function(json){
alert(1);
var dts = json.attributes.dts;
$("#news").empty();
if(typeof(dts)!=undefined){
for(var i=0;i
var b = "
var c = a+b;
// var d ="
$("#news").append(c);
}
}}
});
$('.test2').on('click', function() {
// alert(2);
layer.open({
type: 1,
area: ['600px', '360px'],
shadeClose: true, //点击遮罩关闭
content: '
});
});
});
还是不好使哎 - -
$('.test2').on('click', function()
改成
$('.test2').live('click', function()
id不能重复啊
改完了$.ajax({
type:'POST',
url: 'hhWebsiteInfoController.do?website-getDt',
dataType:'json',
data:'',
success:function(json){
alert(1);
var dts = json.attributes.dts;
$("#news").empty();
if(typeof(dts)!=undefined){
for(var i=0;i
var b = "
var c = a+b;
// var d ="
$("#news").append(c);
}
}}
});
$('.test2').on('click', function() {
// alert(2);
layer.open({
type: 1,
area: ['600px', '360px'],
shadeClose: true, //点击遮罩关闭
content: '
});
});
});
还是不好使哎 - -
$('.test2').on('click', function()
改成
$('.test2').live('click', function()
$('.test2').live('click', function() {
alert(2);
layer.open({
type: 1,
area: ['600px', '360px'],
shadeClose: true, //点击遮罩关闭
content: '
});
});
换了更不好使了= = 本来 页面写死的
换了更不好使了= = 本来 页面写死的还好用呢
live不好用?live就是为当前或未来的匹配元素添加一个或多个事件处理器
你什么版本jquery?1.9+?
那你还是换回on吧
$(document).on("click",".test2",function(){
换了更不好使了= = 本来 页面写死的还好用呢
live不好用?live就是为当前或未来的匹配元素添加一个或多个事件处理器
你什么版本jquery?1.9+?
那你还是换回on吧
$(document).on("click",".test2",function(){
终于好用了
$('.test2').live('click', function() {改了就好了 为啥啊?
还有个问题 大神我要弹出层显示图片链接 在数据库的那条记录的其他内容怎么通过数据库id找到显示啊 ?
终于好用了
$('.test2').live('click', function() {改了就好了 为啥啊?
还有个问题 大神我要弹出层显示图片链接 在数据库的那条记录的其他内容怎么通过数据库id找到显示啊 ?
live方法1.9+不支持了 被on取代了
显示弹层之前,先发条ajax根据id去数据库查出那条信息,把数据带会页面再显示弹层,
注意ajax异步请求和页面赋值的时间差
终于好用了
$('.test2').live('click', function() {改了就好了 为啥啊?
还有个问题 大神我要弹出层显示图片链接 在数据库的那条记录的其他内容怎么通过数据库id找到显示啊 ?
live方法1.9+不支持了 被on取代了
显示弹层之前,先发条ajax根据id去数据库查出那条信息,把数据带会页面再显示弹层,
注意ajax异步请求和页面赋值的时间差
我在这已经查到数据库图片信息的其他字段了$.ajax({
type:'POST',
url: 'hhWebsiteInfoController.do?website-getDt',
dataType:'json',
data:'',
success:function(json){
alert(1);
var dts = json.attributes.dts;
$("#news").empty();
if(typeof(dts)!=undefined){
for(var i=0;i
var b = "
//var d = "";
var c = a+b;
$(".test3").append(c);
$("#news").append(c);
}
这是弹出层
$(document).on('click',".test2",function() {
layer.open({
type: 1,
area: ['600px', '360px'],
shadeClose: true, //点击遮罩关闭
content: '
});
});
});
我觉得$(".test3").append(c);就把别的字段信息加到弹出层了
你建一个全局变量,把dts赋值给它,
ajax循环的时候, class='test2'后边加上自定义属性(举例:dataIndex) 值为 i
var b = "
test2 click事件里先取dataIndex的值 再取前面全局变量对应索引的对象,
然后赋值就行了
test2 click事件里先取dataIndex的值 再取前面全局变量对应索引的对象 然后赋值 这个不懂啊 咋写的..
success:function(json){
alert(1);
var dts = json.attributes.dts;
$("#news").empty();
var quanju = dts;
if(typeof(dts)!=undefined){
for(var i=0;i
var b = "
var d = "";
var c = a+b;
$("#news").append(c);
}
}}
});
$(document).on('click',".test2",function() {
layer.open({
type: 1,
area: ['600px', '360px'],
shadeClose: true, //点击遮罩关闭
content: '
});
});
});
这样?
$(document).on('click',".test2",function() {
layer.open({
type: 1,
area: ['600px', '360px'],
shadeClose: true, //点击遮罩关闭
content: '
});
});
});

HTMLtagsdefinethestructureofawebpage,whileattributesaddfunctionalityanddetails.1)Tagslike,,andoutlinethecontent'splacement.2)Attributessuchassrc,class,andstyleenhancetagsbyspecifyingimagesources,styling,andmore,improvingfunctionalityandappearance.

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use
