属性不应用

it_sql 2009-03-12 08:36:16
var strInner="<div style="+"background-image: url(images/nextbutton.jpg); width: 207px; height: 27px"+"><a href=\"javascript:dosearch(1)\">首页</a> <a href=\"javascript:dosearch("+qianpage+")\">前一页</a> 总共" +totalpage+ "页 <a href=\"javascript:alert('已经是最后一页了!')\">下一页</a> <a href=\"javascript:TurnPage("+properties.length+ ")\">尾页</a> <div>";
var ye=document.getElementById("ye");
ye.innerHTML=strInner
为什么属性没有应用上.
.pimg {float:left;padding:100px;}
.photoTitle{
font-size:9px;
cursor:pointer;
text-align: right;
}
img1.setAttribute("class","pimg");
cell.setAttribute("class","photoTitle");
这样的属性也没有应用上,是什么原因啊?源代码一会贴上

...全文
80 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
mzytechsupport 2009-03-13
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 it_sql 的回复:]
strInner=" <div style="+"background-image: url(images/nextbutton.jpg); width: 207px; height: 27px"+"> </div>"
var ye=document.getElementById("ye");
ye.innerHTML=strInner
这样图片怎么没有显示啊
[/Quote]

你先试试不用脚本,直接把html代码放在页面里看有么有图片。有了再用js写。
mzytechsupport 2009-03-13
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 it_sql 的回复:]
如上面的程序,出来的图片周围都有个框框,是联接的标志,我已经加了下面的CSS了,为什么还会有呢
<style type="text/css">
<!--
a:link { text-decoration: none}
a:active { text-decoration: none }
a:visited { text-decoration: none }
-->
</style>
[/Quote]

应该给图片加样式吧我记得。
it_sql 2009-03-12
  • 打赏
  • 举报
回复
strInner="<div style="+"background-image: url(images/nextbutton.jpg); width: 207px; height: 27px"+"></div>"
var ye=document.getElementById("ye");
ye.innerHTML=strInner
这样图片怎么没有显示啊
it_sql 2009-03-12
  • 打赏
  • 举报
回复
如上面的程序,出来的图片周围都有个框框,是联接的标志,我已经加了下面的CSS了,为什么还会有呢
<style type="text/css">
<!--
a:link { text-decoration: none}
a:active { text-decoration: none }
a:visited { text-decoration: none }
-->
</style>
mzytechsupport 2009-03-12
  • 打赏
  • 举报
回复
class你可以用
var obj=document.getElementById("xxx");
obj.className="你的class";
it_sql 2009-03-12
  • 打赏
  • 举报
回复

function addtablerow(address,price,comments,address1,price1,comments1,address2,price2,comments2)
{
var row=document.createElement("tr"); //建立一行
var cell;
if(address!="")
{
cell=creatimg(address,comments); //创建一个单元格节点
row.appendChild(cell);//把单元格节点增加到建立的行中
}
if(address1!="")
{
cell=creatimg(address1,comments1);
row.appendChild(cell);
}
if(address2!="")
{
cell=creatimg(address2,comments2);
row.appendChild(cell);
}
document.getElementById("resultsbody").appendChild(row); //把行增加到id为resultsbody
row=document.createElement("tr"); //又建立一行
if(price!="")
{
cell=createRlement(address2,price); //创建一个单元格节点
row.appendChild(cell);//把单元格节点增加到建立的行中
}
if(price1!="")
{
cell=createRlement(address1,price1);
row.appendChild(cell);
}
if(price2!="")
{
cell=createRlement(address2,price2);
row.appendChild(cell);
}

document.getElementById("resultsbody").appendChild(row); //把行增加到id为resultsbody

}
function createRlement(text,text1)
{

var cell =document.createElement("td") //常见一个节点
var tableNode=document.createTextNode(text1); //创建一个文本节点
cell.appendChild(tableNode);//把文本赋值给cell
cell.setAttribute("text-align","center");
cell.setAttribute("onmouseover",function(){this.style.backgroundColor="#CBE83E"});
cell.setAttribute("onmouseout",function(){this.style.backgroundColor="#FFFFFF"});
cell.setAttribute("class","photoTitle");

return cell;//返回cell
}
function creatimg(text,text1)
{
var cell =document.createElement("td");
var a=document.createElement("a");
a.setAttribute("href","show?id="+text);
a.setAttribute("target","_blank");
var img1 =document.createElement("img");
img1.setAttribute("src",text1);
img1.setAttribute("class","pimg");
a.appendChild(img1);
cell.appendChild(a);
cell.setAttribute("border","1");
return cell;
}



添加的属性好象都不能应用上,为什么呢?
it_sql 2009-03-12
  • 打赏
  • 举报
回复

function parseresult()
{


var result=xmlhttp.responseXML; //获得xmlhttp对象的responseXML的属性值
var property=null; //声明局部变量
var address="";
var price="";
var comments="";//声明局部变量
var address1="";
var price1="";
var comments1="";//声明局部变量
var address2="";
var price2="";
var comments2="";//声明局部变量
var properties=result.getElementsByTagName("book"); //返回property的子元素数组
var strInner;
var nextpage=CurPage+1
var totalpage=properties.length/PageTab;

if( CurPage==1)
{

strInner="<div style="+"background-image: url(images/nextbutton.jpg); width: 207px; height: 27px"+"><a href=\"javascript:dosearch(1)\">首页</a> <a href=\"javascript:alert('已经是第一页了!')\">前一页</a> 总共" +totalpage+ "页 <a href=\"javascript:dosearch("+nextpage+")\">下一页</a> <a href=\"javascript:TurnPage(" +properties.length+ ")\">尾页</a> <div>";

}

else if( CurPage==totalpage)
{
var qianpage=CurPage-1;
strInner="<div style="+"background-image: url(images/nextbutton.jpg); width: 207px; height: 27px"+"><a href=\"javascript:dosearch(1)\">首页</a> <a href=\"javascript:dosearch("+qianpage+")\">前一页</a> 总共" +totalpage+ "页 <a href=\"javascript:alert('已经是最后一页了!')\">下一页</a> <a href=\"javascript:TurnPage("+properties.length+ ")\">尾页</a> <div>";
}
else
{
var qianpage=CurPage-1;
strInner="<div style="+"background-image: url(images/nextbutton.jpg); width: 207px; height: 27px"+"><a href=\"javascript:dosearch(1)\">首页</a> <a href=\"javascript:dosearch("+qianpage+")\">前一页</a> 总共" +totalpage+ "页 <a href=\"javascript:dosearch("+nextpage+")\">下一页</a> <a href=\"javascript:TurnPage(" +properties.length+ ")\">尾页</a> <div>";
}
var ye=document.getElementById("ye");
ye.innerHTML=strInner
var i;

if( CurPage==1)
{
i=0
}
else
{
i=(CurPage-1)*PageTab
}
var j=CurPage*PageTab;
while (i< j)
{
property=properties[i];
address=property.getElementsByTagName("id")[0].firstChild.nodeValue; //取得address元素的第一个下级子元素
price=property.getElementsByTagName("title")[0].firstChild.nodeValue;  //取得price元素的第一个下级子元素
comments=property.getElementsByTagName("img")[0].firstChild.nodeValue; //取得comments元素的第一个下级子元素
i=i+1;
if(i<properties.length)
{

property=properties[i];
address1=property.getElementsByTagName("id")[0].firstChild.nodeValue; //取得address元素的第一个下级子元素
price1=property.getElementsByTagName("title")[0].firstChild.nodeValue;  //取得price元素的第一个下级子元素
comments1=property.getElementsByTagName("img")[0].firstChild.nodeValue; //取得comments元素的第一个下级子元素
i=i+1;
}
if(i<properties.length)
{
property=properties[i];
address2=property.getElementsByTagName("id")[0].firstChild.nodeValue; //取得address元素的第一个下级子元素
price2=property.getElementsByTagName("title")[0].firstChild.nodeValue;  //取得price元素的第一个下级子元素
comments2=property.getElementsByTagName("img")[0].firstChild.nodeValue; //取得comments元素的第一个下级子元素
i=i+1
}

addtablerow(address,price,comments,address1,price1,comments1,address2,price2,comments2); //添加行
address="";
price="";
comments="";
address1="";
price1="";
comments1="";
address2="";
price2="";
comments2="";
}

}

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧