正确解码包含c#\ u003c或\ u00252等字符串的文本(Properly decode a text that contains strings like \u003c or \u00252 in c#)
我有一个JSon响应,里面包含很多\ u003c或\ u00252或其他类似的字符串。 我需要一个合适的函数才能将这些字符串解码为正确的字符。
I have a JSon response that contains lots of \u003c or \u00252 or other similar strings inside. I need a proper function in order to decode these strings into proper characters.
原文:https://stackoverflow.com/questions/6149479
最满意答案
为了增加输入和标签字段的ID和FOR,您可以使用:
在你的CSS你需要改变:
.field-r input[type="radio"]#coming-yes+label { cursor: url('/assets/images/happy.png'), pointer; } .field-r input[type="radio"]#coming-no+label { cursor: url('/assets/images/sad.png'), pointer; }
至:
.field-r input[type="radio"].coming-yesRadio+label { cursor: url('/assets/images/happy.png'), pointer; } .field-r input[type="radio"]..coming-noRadio+label { cursor: url('/assets/images/sad.png'), pointer; }
相反,要在CSS中通过id来处理每个元素,您可以使用一个类。 这意味着将相应的类添加到您的输入元素。
片段:
$('.addguest').on('click', function(e) { e.preventDefault(); // // get the current number of ele and increment it // var i = $('.guest').length + 1; $('.guest').first().clone().find("input").attr('id', function(idx, attrVal) { return attrVal + i; // change the id }).attr('name', function(idx, attrVal) { return attrVal + i; // change the name }).val('').removeAttr('checked').end().find('label').attr('for', function(idx, attrVal) { return attrVal + i; // change the for }).end().insertBefore(this); });
@font-face { font-family: 'dk_vermilionregular'; src: url('http://adrianandemma.com/assets/fonts/dk_vermilion-webfont.woff2') format('woff2'), url('http://adrianandemma.com/assets/fonts/dk_vermilion-webfont.woff') format('woff'); font-weight: normal; font-style: normal; } * { font-weight:normal; box-sizing:border-box; font-family:'dk_vermilionregular', arial, sans-serif; } body { font-family:'dk_vermilionregular', arial, sans-serif; color:#363e3f; line-height: 1.2; } .box { text-align:center; max-width: 60%; margin:0 auto; } h1 { font-size:86px; margin:0.5em 0; } h1 span { display:block; font-size: 40px; } h2 { font-size:68px; margin:0.5em 0; } p { font-size: 40px; margin:0.5em 0; } a { color: #363e3f; } a.btn { display: inline-block; font-size:24px; color:#363e3f; text-decoration: none; padding:12px 20px 8px; border:1px solid #363e3f; margin: 20px 0 0; } /*** Images ***/ img { max-width:100%; } img.ae { width:260px; } img.ceremony { width:300px; margin:0 0 20px; } /*** Forms ***/ #rsvp { z-index: 110; display: table; table-layout: fixed; position: fixed; width:100%; height: 100%; top: 0px; bottom: 0px; left: 0px; right: 0px; background: rgba(255,255,255,1); } .form-container { display: table-cell; vertical-align: middle; } form { width: 600px; max-width: 60%; margin:0 auto; } form p { font-size:24px; margin: 0; } .form-row { overflow: auto; margin:0 0 10px; } .field-l { float:left; width: 70%; padding-right: 20px; } .field-r { float:right; width: 30%; text-align: right; cursor: default; } .field-l input { display:block; width: 100%; height: 40px; vertical-align: middle; padding: 0 10px; box-shadow: none; border:1px solid #363e3f; } .field-r label { font-size:20px; height: 40px; line-height: 40px; display: inline-block; padding: 0 10px; border: 1px solid #ddd; width: 40%; margin:0 0 0 5px; text-align: center; } .field-r input[type="radio"]:checked+label { border: 1px solid #363e3f; } .field-r input[type="radio"].coming-yesRadio+label { cursor: url('http://adrianandemma.com/assets/images/happy.png'), pointer; } .field-r input[type="radio"].coming-nosRadio+label { cursor: url('http://adrianandemma.com/assets/images/sad.png'), pointer; } .field-r input { width: 0; margin: 0; visibility: hidden; cursor: default; } form button { display: block; width:100%; border:1px solid #363e3f; background: #fff; margin:30px 0 0; font-size: 24px; padding: 10px 0 7px; cursor: pointer; } form button:hover { background: #fcfcfc; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="form-row guest"> <div class="field-l"> <input type="text" name="name" id="name" required /> </div> <div class="field-r"> <input type="radio" name="coming" class="coming-yesRadio" id="coming-yes" value="Yes" required><label for="coming-yes">Yes</label> <input type="radio" name="coming" class="coming-yesRadio" id="coming-no" value="No"><label for="coming-no">No</label> </div> </div> <a class="addguest" href="#">Add further guest</a>
In order to increment the IDs and FORs of your input and label fields you can use:
.attr( attributeName, function )
In your css you need to change from:
.field-r input[type="radio"]#coming-yes+label { cursor: url('/assets/images/happy.png'), pointer; } .field-r input[type="radio"]#coming-no+label { cursor: url('/assets/images/sad.png'), pointer; }
To:
.field-r input[type="radio"].coming-yesRadio+label { cursor: url('/assets/images/happy.png'), pointer; } .field-r input[type="radio"]..coming-noRadio+label { cursor: url('/assets/images/sad.png'), pointer; }
Instead to address each element by id in your CSS you may use a class. That means to add the corresponding class to your input elements.
The snippet:
$('.addguest').on('click', function(e) { e.preventDefault(); // // get the current number of ele and increment it // var i = $('.guest').length + 1; $('.guest').first().clone().find("input").attr('id', function(idx, attrVal) { return attrVal + i; // change the id }).attr('name', function(idx, attrVal) { return attrVal + i; // change the name }).val('').removeAttr('checked').end().find('label').attr('for', function(idx, attrVal) { return attrVal + i; // change the for }).end().insertBefore(this); });
@font-face { font-family: 'dk_vermilionregular'; src: url('http://adrianandemma.com/assets/fonts/dk_vermilion-webfont.woff2') format('woff2'), url('http://adrianandemma.com/assets/fonts/dk_vermilion-webfont.woff') format('woff'); font-weight: normal; font-style: normal; } * { font-weight:normal; box-sizing:border-box; font-family:'dk_vermilionregular', arial, sans-serif; } body { font-family:'dk_vermilionregular', arial, sans-serif; color:#363e3f; line-height: 1.2; } .box { text-align:center; max-width: 60%; margin:0 auto; } h1 { font-size:86px; margin:0.5em 0; } h1 span { display:block; font-size: 40px; } h2 { font-size:68px; margin:0.5em 0; } p { font-size: 40px; margin:0.5em 0; } a { color: #363e3f; } a.btn { display: inline-block; font-size:24px; color:#363e3f; text-decoration: none; padding:12px 20px 8px; border:1px solid #363e3f; margin: 20px 0 0; } /*** Images ***/ img { max-width:100%; } img.ae { width:260px; } img.ceremony { width:300px; margin:0 0 20px; } /*** Forms ***/ #rsvp { z-index: 110; display: table; table-layout: fixed; position: fixed; width:100%; height: 100%; top: 0px; bottom: 0px; left: 0px; right: 0px; background: rgba(255,255,255,1); } .form-container { display: table-cell; vertical-align: middle; } form { width: 600px; max-width: 60%; margin:0 auto; } form p { font-size:24px; margin: 0; } .form-row { overflow: auto; margin:0 0 10px; } .field-l { float:left; width: 70%; padding-right: 20px; } .field-r { float:right; width: 30%; text-align: right; cursor: default; } .field-l input { display:block; width: 100%; height: 40px; vertical-align: middle; padding: 0 10px; box-shadow: none; border:1px solid #363e3f; } .field-r label { font-size:20px; height: 40px; line-height: 40px; display: inline-block; padding: 0 10px; border: 1px solid #ddd; width: 40%; margin:0 0 0 5px; text-align: center; } .field-r input[type="radio"]:checked+label { border: 1px solid #363e3f; } .field-r input[type="radio"].coming-yesRadio+label { cursor: url('http://adrianandemma.com/assets/images/happy.png'), pointer; } .field-r input[type="radio"].coming-nosRadio+label { cursor: url('http://adrianandemma.com/assets/images/sad.png'), pointer; } .field-r input { width: 0; margin: 0; visibility: hidden; cursor: default; } form button { display: block; width:100%; border:1px solid #363e3f; background: #fff; margin:30px 0 0; font-size: 24px; padding: 10px 0 7px; cursor: pointer; } form button:hover { background: #fcfcfc; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="form-row guest"> <div class="field-l"> <input type="text" name="name" id="name" required /> </div> <div class="field-r"> <input type="radio" name="coming" class="coming-yesRadio" id="coming-yes" value="Yes" required><label for="coming-yes">Yes</label> <input type="radio" name="coming" class="coming-yesRadio" id="coming-no" value="No"><label for="coming-no">No</label> </div> </div> <a class="addguest" href="#">Add further guest</a>
相关问答
更多-
用jQuery克隆表单字段并增加'id'和'for'属性?(Clone form fields with jQuery and increment 'id' and 'for' attributes?)[2024-02-06]
为了增加输入和标签字段的ID和FOR,您可以使用: .attr(attributeName,function) 在你的CSS你需要改变: .field-r input[type="radio"]#coming-yes+label { cursor: url('/assets/images/happy.png'), pointer; } .field-r input[type="radio"]#coming-no+label { cursor: url('/assets/images/sa ... -
jQuery:克隆一个div并在顺序id的最后一个div之后插入它(jQuery: clone a div and insert it after last div with sequential id)[2023-03-29]
而不是克隆div,你可以使用该div的html来添加它 $('#add').on('click', function () { var id = $(".addr:last").attr('id'); var appendDiv = jQuery($(".addr:last")[0].outerHTML); appendDiv.attr('id', ++id).insertAfter(".addr:last"); }); Instead of ... -
由于没有人提供了这样的答案,即使在一个赏金之后,我终于设法让这个工作自己了。 这不应该是一个坏消息! 希望这将在Rails 3.0中更容易做到。 Andy的例子是直接删除记录,而不是将表单提交给服务器的好办法。 在这种特殊情况下,我真正寻找的是在对嵌套表单进行更新之前动态添加/删除字段的方法。 这是一个稍微不同的情况,因为当字段被删除时,它们实际上不会被删除,直到表单被提交。 我可能最终会根据情况使用两者。 我基于Tim Riley在github上的复杂形式示例 fork的实现。 首先设置模型,并确保它们支 ...
-
使用jQuery添加表单字段(wordpress中的联系人7表单)(Adding form fields with jQuery (contact 7 form in wordpress))[2022-03-29]
您尚未将点击事件附加到节目或点击此处链接。 为他们添加一个ID和您想要显示的div。 然后将您的JS改为如下所示的内容: $(document).ready(function() { $('#show').click(function () { $("#hiddencontent").fadeIn("slow"); }); }); 因此,在这种情况下,您可以向点击此处的号召性用语添加展示ID,并将隐藏内容的ID添加到您想要显示的隐藏内容中。 原因在于你对于你想与之交互的元素没有足够的具体细节 ... -
您的代码中有两个错误。 使用.find() ,不应在选择器上包含jQuery包装器。 使用.find("input[id^='keywords_'],select[id^='keywords_']") 。 您还需要将新属性应用于元素,因为replace返回一个字符串。 小提琴 var next_index = 1; var $container = $(".search_container"); var $new_container = $container.clone(); $new_container. ...
-
单击div-jQuery需要增加/减少输入字段名称(Need increment/decrement input fields name by clicking div- jQuery)[2023-10-06]
首先,由于您正在克隆并附加html元素,因此不应使用id ,因为id不能在页面中多次出现。 相反,你应该使用类。 对于您的解决方案,您可以这样做: $('#add_agent').click(function(e){ var $htmlTemplate = $('.add_new_agent').find('.add_agent_div:first').clone(true); $htmlTemplate.find('.count_agent').text($('.add_new_ ... -
假设你要经常这样做一次。 //Somewhere global var counter = 0; //Order Form $("#add").click(function() { counter++; var cln = $('#ordertable tbody>tr:last').clone(true); cln.find("[id^='prodcode'], [id^='meterage']").each(function(i, val) { val.id = ...
-
使用JQuery更改动态添加的表单字段的输入ID(Change input id for dynamically added form fields using JQuery)[2023-07-03]
要更改您的案例ID中的item属性,此行可能会有所帮助: var NewIdValue = "Somthing" ; $('#OldIdValue').attr('id') = NewIdValue; to change the item attribute which is in your case id this line may be helpful : var NewIdValue = "Somthing" ; $('#OldIdValue').attr('id') = NewIdValue; ... -
你可以为此获取一些正则表达式和parseInt() 。 例如 element.attr('name', element.attr('name').replace(/(.*form\-)(\d+)(\-.*)/, function(f, p1, p2, p3) { return p1 + (parseInt(p2) + 1) + p3; })); 然而,只有一个重要的警告: 在jQuery中更改克隆输入元素的名称attr在IE6 / 7中不起作用 Here is the solution I hav ...
-
你可以使用each : $.each($("input"), function(index, item) { var type = $(this).attr("type"); var val = $(this).val(); //do your checking... if (type == "text") { //and so on... } }); 请注意,我使用$(this)来访问项目,而不是item参数参数 - 在使用input元素时使用it ...