Tag: javascript

如何将php变量传递给jquery

我尝试将php变量传递给jquery,我已经尝试使用了 但是当我尝试使用时,它并没有取得成功 dataSource:insted dataSource: [ { childName: “Child1”, childId: 1, parentId: 1 }, { childName: “Child2”, childId: 2, parentId: 2 }, { childName: “Child3”, childId: 3, parentId: 1 }, { childName: “Child4”, childId: 4, parentId: 2 } ] 它不能显示第二个选择,但我发现$ data与原始数据相同 我的代码, Kendo UI Snippet $(“#parent”).kendoDropDownList({ dataTextField: “parentName”, dataValueField: “parentId”, dataSource: [ { parentName: “Parent1”, parentId: […]

json数据检查是否重复相同的id

我有一个json数据,其中一个id有不同的color_id。 所以从那里我只想检查同一个id是否重复然后只保留第一个 这是我的示例JSON var data= [{ “id”: “1”, “name”: “xxx”, “age”: “22”,”color_id”: “22” }, { “id”: “1”, “name”: “yyy”, “age”: “15”,”color_id”: “1” }, { “id”: “5”, “name”: “zzz”, “age”: “59”,”color_id”: “22” }]; 我想要的输出 var data= [{ “id”: “1”, “name”: “xxx”, “age”: “22”,”color_id”: “22” }, { “id”: “5”, “name”: “zzz”, “age”: “59”,”color_id”: “22” }]; 我尝试减少但在那里我发现修改数据结构所以我不确定我是否会得到我想要的输出。

在下拉列表中旋转自定义图像作为箭头

我按照在线教程帮助我用我自己的图像替换浏览器的默认下拉选择箭头。 这很好,你可以在这里看到这个例子。 .headerDropdown { border-radius: 6px; border: 2px solid #d4d4d4; height: 34px; } .headerDropdown select { height: 34px; line-height: 34px; padding-left: 10px; padding-right: 5px; margin-right: 20px; font-size: 16px; border: 0 !important; /*Removes border*/ -webkit-appearance: none; /*Removes default chrome and safari style*/ -moz-appearance: none; /*Removes default style Firefox*/ background: url(“http://sofzh.miximages.com/javascript/caret-black-small-up-icon.png”) right no-repeat; width: 100%; background-position: 98% […]

使用jquery自动完成我试图获取文本框中的值作为表数据不是来自json使用文本字段中的ajax

这是我第一次使用带有json的ajax进行自动完成(Jquery),结果看起来像是自动完成,但结构(输出)看起来像表。 这是我的jquery代码 $(“document”).ready(function (){ $(function () { $.ajax({ url: “dummy.json”, success: function(){ alert(“got the file”); }, error:function (xhr, ajaxOptions, thrownError){ console.log(xhr.status); console.log(thrownError); } }); return false; }); }); 这是我的json数据 { “schoolname”:{ “school”:[ { “id”:”1″, “description”:”COL000001″, “schoolname”:”Emirates College of Technology- UAE” }, { “id”:”2″, “description”:”COL000002″, “schoolname”:”Al Khawarizmi International College- UAE” }, { “id”:”3″, “description”:”COL000003″, “schoolname”:”Syscoms College” […]

jquery.form / validate插件仅允许在输入更改时提交

我想使用jQuery.Form / Validate插件,只允许在任何输入实际更改时提交我的表单。 使用beforeSubmit: :: http://jquery.malsup.com/form/#options-object有回调逻辑。 但是,我似乎无法使其发挥作用。 这是我到目前为止所拥有的: $(document.body).on(‘click’, ‘input[type=”submit”]’, function(){ var $form =$(‘form’); $form.validate({ submitHandler: function($form) { $($form).ajaxSubmit({ beforeSubmit: function(arr, $form){ var value = ”, storedValue=”; $($form+’:input’).each(function (index, el) { value=$(el).val(); storedValue=$(el).data(“stored”); if(value!=storedValue){ console.log(“Changed”); return true; } else { return false; console.log(“NOT changed”); } }); …success handling, etc.. beforeSubmit: function(arr, $form) { var value […]

使用Javascript进行Div布局

使用Javascript进行Div布局 如果我点击+它应该打开它再次点击 – 它应该是关闭它工作正常但我需要的是,如果有更多的div如何在运行时处理它们。 #widnow{ width:100%; border:solid 1px; float:left; } #title_bar{ background: #FEFEFE; height: 25px; width: 100%; } #button{ border:solid 1px; width: 25px; height: 23px; float:right; cursor:pointer; } .box{ height: 50%; width: 50%; background: #DFDFDF; float:left; } #title_bar1{ background: #FEFEFE; height: 25px; width: 100%; } #button1{ border:solid 1px; width: 25px; height: 23px; float:right; cursor:pointer; } […]

突出显示母版页中的活动菜单项

我正在使用我的菜单项的主人。 由于我使用母版页,我很困惑如何突出显示活动菜单项。 谁能帮我吗。 由于我有4个页面,我在4页的所有页面加载事件中尝试了以下代码并且无法正常工作。 if (!IsPostBack) { Menu M = (Menu)this.Master.FindControl(“menu”); foreach (MenuItem item in M.Items) { if (item.Text == “update”) { item.Selected = true; } } } Update Bulk Profiles Help #menu ul { margin: 0; padding: 7px 6px 0; background: #b6b6b6 url(‘/Images/Overlay.png’) repeat-x 0 -110px; line-height: 100%; border-radius: 1em; font: normal 0.5333333333333333em Arial, […]

使用Ajax将图像发送到数据库(php)而无需重新加载

我创建了一个bootstrap模式弹出窗体,在图库页面中添加图片,我开发了php和ajax代码,因为我想在这里没有页面重新加载: – 问题是,当我想将图像发送到数据库时,我显示此错误 Notice: Undefined index: photo in …. 我无法发送图片。 这是我的ajax代码 $(function() { //twitter bootstrap script $(“button#submit”).click(function(){ $.ajax({ type: “POST”, url: “image.php”, data: $(‘form.contact’).serialize(), success: function(msg){ $(“#thanks”).html(msg) $(“#myModal”).modal(‘hide’); }, error: function(){ alert(“failure”); } }); }); }); 这是Image.php文件 include ‘db.php’; if(isset($_POST[‘titre’])){ $titre = strip_tags($_POST[‘titre’]); $image_name = $_FILES[‘photo’][‘name’]; $image_tmp = $_FILES[‘photo’][‘tmp_name’]; $image_size = $_FILES[‘photo’][‘size’]; $image_ext = pathinfo($image_name, […]

克隆其中包含文本的字段也会克隆文本?

我有一段克隆三个字段的代码,但是当它克隆了三个字段时,它还克隆了在其中输入的文本,有没有办法在克隆时清除字段内的内容? $(document).ready(function() { $(‘#btnAdd’).click(function() { var num = $(‘.clonedSection’).length; var newNum = new Number(num + 1); var newSection = $(‘#clonedSection’ + num).clone().attr(‘id’, ‘clonedSection’ + newNum); newSection.children(‘:first’).children(‘:first’).attr(‘id’, ‘name’ + newNum).attr(‘name’, ‘name’ + newNum); newSection.children(‘:nth-child(2)’).children(‘:first’).attr(‘id’, ‘age’ + newNum).attr(‘name’, ‘age’ + newNum); newSection.children(‘:nth-child(3)’).children(‘:first’).attr(‘id’, ‘school’ + newNum).attr(‘name’, ‘school’ + newNum); $(‘.clonedSection’).last().append(newSection); $(‘.clonedSection’).last().val(ping); $(‘#btnDel’).attr(‘disabled’,”); if (newNum == 2) $(‘#btnAdd’).attr(‘disabled’,’disabled’); }); […]

使用Jquery动态加载的html类

我有一个带有类产品div的动态加载页面。 Jquery没有使用下面的代码看到这个类。 当我点击产品divs时它没有做任何事情。 然而,导航元素上的陈词滥调很好。 有什么方法可以使它吗? $(document).ready(function(){ $(“.nav-element”).click(function(){ var id = $(this).attr(‘id’); alert(id); $(“.nav-element”).css(“background”, “#fff”); $(“#”+id).css(“background”, “#A4CFBE”); $(“.content-white”).load(id+”.html”); }); $(“.content-white”).load(“nav-element1.html”); $(“.product”).click(function(){ alert(“poop”); }) });