小编bom*_*mbo的帖子

将javascript字符串转换为html对象

我可以将字符串转换为html对象吗?喜欢:

string s = '<div id="myDiv"></div>';
var htmlObject = s.toHtmlObject;
Run Code Online (Sandbox Code Playgroud)

所以我以后可以通过id获取它并做一些改变它的风格

var ho = document.getElementById("myDiv").style.marginTop = something;
Run Code Online (Sandbox Code Playgroud)

丽娜,提前100万

html javascript

66
推荐指数
4
解决办法
28万
查看次数

如何在ASP.NET MVC中使用flot和jQuery?

我正在尝试学习如何使用Flot,我认为你的例子是一个非常好的,简单的,非常容易理解的代码,所以我一直在尝试实现它,但这里是我在index.aspx中的代码:

$(function () {
    $.getJSON("../../Home/JsonValues", function (data) {
        alert('json: ' + data + ' ...');
        var plotarea = $("#plot_area");
        $.plot(plotarea, data);
        //$.plot(plotarea,[ [[0, 0], [1, 1]] ]);
    });
});
Run Code Online (Sandbox Code Playgroud)

这是HomeController中的代码:

public ActionResult JsonValues()
{
    //string s = "[ [[0, 0], [1, 1]] ]";
    //return Json(s, JsonRequestBehavior.AllowGet);
    StringBuilder sb = new StringBuilder();
    sb.Append("[[0, 0], [1, 1]]");
    return Json("[" + sb.ToString() + "]", JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)

我得到的只是一个空图,尽管在索引中发出警报.我得到了完美的格式化JSON数据.

我究竟做错了什么?

asp.net asp.net-mvc jquery json flot

7
推荐指数
1
解决办法
5682
查看次数

javascript getElementById并将其转换为String

有没有办法将javascript HTML对象转换为字符串?即

var someElement = document.getElementById("id");
var someElementToString = someElement.toString();
Run Code Online (Sandbox Code Playgroud)

非常感谢提前

javascript

5
推荐指数
1
解决办法
4万
查看次数

如何使用javascript提交表单后保留表单数据?

当我提交此表单时,值只会从文本框中消失.我喜欢他们留在文本框中打印.我怎么做?

<form id="myform" method="get" action="" onSubmit="hello();">

       <input id="hour" type="text" name="hour" style="width:30px; text-align:center;" /> :
       <input id="minute" type="text" name="minute" style="width:30px; text-align:center;" />
       <br/>
       <input type="submit" value="Validate!" />
    </form>

    <style type="text/css">
    .error {
        color: red;
        font: 10pt verdana;
        padding-left: 10px
    }
    </style>
<script type="text/javascript">
function hello(){

    var hour = $("#hour").html();
    alert(hour);
}
    $(function() {
        // validate contact form on keyup and submit
        $("#myform").validate({
            //set the rules for the fild names
            rules: {
                hour: {
                    required: true,
                    minlength: 1,
                    maxlength: 2,
                    range:[0,23]
                }, …
Run Code Online (Sandbox Code Playgroud)

javascript forms

5
推荐指数
2
解决办法
3万
查看次数

如何遍历configurationSection

我的Web.config文件中有以下部分:

<configSections>
    <section name="mySection" type="myNameSpace, myProject"/>
</configSections>


<mySection>
    <city id="ny" type="nameSpace1" />
    <city id="dc" type="nameSpace2" />
    <city id="nj" type="nameSpace3" />
</mySection>
Run Code Online (Sandbox Code Playgroud)

我需要编写循环遍历cities给定的代码id并返回type.

 if the given id = "ny" --> return nameSpace1
 if the given id = "dc" --> return nameSpace2
 if the given id = "nj" --> return nameSpace3
Run Code Online (Sandbox Code Playgroud)

c# configurationsection

5
推荐指数
1
解决办法
1728
查看次数

如何使用jquery更改输入字段的值?

我正在尝试使用jquery来更改输入文本框的值,但它不起作用,这是我的代码...

    <form method="get">
            <input id="temp" type="text" name="here" value="temp value" />
            <input class="form" type="radio" value="1" name="someForm" /> Enter something
            Here: <input id="input" type="text" name="here" value="test value" />
    </form>

    <script>

    $(document).ready(function () {
        $('.form').click(function () {
            var newvalue = $("#input").val();
            $("#temp").val(newvalue);
            $("#input").val($("#temp").val());
        });
    });

</script>
Run Code Online (Sandbox Code Playgroud)

"#input"文本框的值没有改变!!!!!! 这是为什么???我错过了什么?感谢1000万提前ps文本框的值正在改变,但输入的值属性不是!即使我写...

var value = $("#temp").val();
$("#input").attr("value", value);
Run Code Online (Sandbox Code Playgroud)

jquery

4
推荐指数
1
解决办法
1万
查看次数

如何将背景图像适合包含的锚元素?

我正在尝试设计一个带有图像背景的链接,问题是图像是否太大,我如何使用css将其与锚点的宽度和高度相匹配?

<a href="#"></a>
<style>
 a
 {  
    display: block;
    padding: 5px 12px;
    border: 1px solid black;
    width: 10px;
    height: 10px;
    background-image: url('/Scripts/images/downarrow_blue.png');
    }
</style>
Run Code Online (Sandbox Code Playgroud)

蒂娜,丽娜

css

3
推荐指数
1
解决办法
6384
查看次数

使div宽度拉伸以适合其内容

我有以下HTML代码:

<table>
  <tr>
    <td>
      <div id="fixmywidth" style="position:relative; height:30px;">
        <div style="z-index: 2000; margin-top: 5px; height: inherit; position: absolute;">
          <table style="height:inherit">
            <tr style="height:inherit">
              <td align="center" style="width: 31px; height: inherit;">&nbsp;</td>
              <td align="center" style="width: 31px; height: inherit;">&nbsp;</td>
              <td align="center" style="width: 31px; height: inherit;">&nbsp;</td>
              <td align="center" style="width: 31px; height: inherit;">&nbsp;</td>
              <td align="center" style="width: 31px; height: inherit;">&nbsp;</td>
              <td align="center" style="width: 31px; height: inherit;">&nbsp;</td>
              ........300 tds later
              <td align="center" style="width: 31px; height: inherit;">&nbsp;</td>
            </tr>
          </table>
        </div>
      </div>
    </td>
  </tr>
</table> 
Run Code Online (Sandbox Code Playgroud)

如何使用id"fixmywidth"宽度的div适合包含元素的宽度?我试过宽度= 100%并且widht = auto但他们不会工作,感谢提前一万亿,丽娜

html css

1
推荐指数
1
解决办法
5494
查看次数

使用javascript限制可接受输入的选择

是否可以阻止用户使用javascript将文字写入文本框(即强制用户仅在文本框中输入数字)?

javascript

0
推荐指数
1
解决办法
186
查看次数

标签 统计

javascript ×4

css ×2

html ×2

jquery ×2

asp.net ×1

asp.net-mvc ×1

c# ×1

configurationsection ×1

flot ×1

forms ×1

json ×1