日期:2014-05-16  浏览次数:20357 次

利用js有没有办法手动设置DIV宽高等信息呢?

var change_w = $(".topfloat").width();//width
var change_h = $(".topfloat").height();//height
var change_u = $(".topfloat a").attr("href");//url
var change_s = $(".topfloat img").attr("src");//src
var change_t = $(".topfloat img").attr("title");//title
$(".change_W").attr("value",change_w);
$(".change_H").attr("value",change_h);
$(".change_Url").attr("value",change_u);
$(".change_Url_P").attr("value",change_s);
$(".change_Title").attr("value",change_t);


可不可以这样修改呢?
表单  form type="form-xxxx media???" 怎么写呢?

坐等大神.

------解决方案--------------------
点击确定后修改div的style 
------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> New Document </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <script type="text/javascript">
  <!--
function chgbig(){
var divobj = document.getElementById("div1");
divobj.style.width = parseInt(divobj.style.width)+10;
divobj.style.height = parseInt(divobj.style.height)+10;
}
  //-->
  </script>
 </head>

 <body>
  <button onclick="chgbig()">变大</button>
  <div id="div1" style="border:1px black solid;background-color:#cfcfcf;width:300px;height:300px">
  </div>
 </body>
</html>

------解决方案--------------------

<style>
#div1{height:100px;width:100px;background-color:yellow}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("#abv").click(function(){
$("#div1").height($("#hei").val()).width($("#wid").val());
});
})
</script>
<div id="div1"></div>
宽<input type="text" id="wid"/>
高<input type="text" id="hei"/>
<input type="button" id="abv" value="确定"/>

------解决方案--------------------
刷新必然样式重置,想要保存样式不一定非得借助后端语言,可以把状态存入cookie中(jquery提供该插件)或者localstorage中,方法自己百度一下,满意的话请结贴吧。

引用:
Quote: 引用:


<style>
#div1{height:100px;width:100px;background-color:yellow}
</sty