<?php
if(isset($_GET['value'])){
echo ?>
HTML CODE GOES HERE
<?php
;
}
?>
Run Code Online (Sandbox Code Playgroud)
可以完成这样的事情吗?我的脚本出现了红色错误.
我正在尝试学习jquery mobile,我想知道jquery mobile是否可以与PHP一起使用,好像我正在建立一个常规网站?
与jquery移动标签几乎相同,但他们使用数据角色等标签,
indext.html
<div data-role="header">
<div data-role="content">
content page
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我能做点什么吗
的index.html
<div data-role="header">
<div data-role="content">
<?php echo $content; //this content will be populated by mysql
?>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
或者我是否必须使用ajax来获取内容?
的index.html
$(document).ready(function(){
$.ajax({
url: "test.html",
success: function(data){
$('.page1').html(data);
}
});
});
<div data-role="header">
<div data-role="content" class='page1'>
<?php echo $content; //this content will be populated by mysql
?>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
的test.html
<?php
$sql = mysql_query("SELECT * FROM test");
while($q = mysql_fetch_array($sql)){
$content = $q['content'];
echo $content;
}
?>
Run Code Online (Sandbox Code Playgroud) 我有一个计数器,我试图用jquery检索该数字并添加到它.
<div id='counter'>
32
</div>
Run Code Online (Sandbox Code Playgroud)
所以我试图用jquery获取32,然后添加到它,+ 1.
var counter = $('#counter').text();
var counterPlus = counter++;
Run Code Online (Sandbox Code Playgroud)
这应该有用吗?它对我不起作用
我正在尝试通过jQuery的.each()函数建立一个数组,但似乎我没有正确地做到这一点?
我在html中有属性,例如:
<div class="cheers" data-fname = "fname" data-lname="lname">some ish..</div><!-- going through a while loop!-->
Run Code Online (Sandbox Code Playgroud)
然后我有一个jquery函数,做这样的事情
var arrayMe = [];
$(".cheers").each(function(index){
arrayMe[index] = $(".cheers").attr('data-fname')+","+$(".cheers").attr('data-lname');
});
Run Code Online (Sandbox Code Playgroud)
然后,当我尝试做各种警报时:
alert(arrayMe); //this gives me the fname,lname
alert(arrayMe[0]); //this gives me the first fname,lname in the array
alert(arrayMe[0][1]); //this SUPPOSED to give me the first lname, but it gives me a letter...
Run Code Online (Sandbox Code Playgroud) 我有点理解.eq()函数在jquery中是如何工作的,
<ul>
<li>item 2</li>
<li>item 4</li>
<li>item adf</li>
<li>item f</li>
</ul>
$('ul').find('li').eq(3); //this gives item f
Run Code Online (Sandbox Code Playgroud)
但是,如果我想点击项目adf,我该怎么得到2的警报呢?
$('ul li').click(function(){
alert('//getting eq value'); //and then when clicked, it should say 2
});
Run Code Online (Sandbox Code Playgroud)
谢谢
我想知道是否有一种方法可以传递这样的变量:
<script type="text/javascript">
width = 300;
</script>
<script type="text/javascript">
(function(){
var k = width;
alert(k);
});
</script>
Run Code Online (Sandbox Code Playgroud)
我正在努力学习如何将宽度传递给变量k.我不想做var width =300有没有办法做这样的事情?所以最终我可以把底部脚本(function(){...});放到一个文件中,我可以这样做
<script type="text/javascript">
width = 300;
//more variables if needed
//height = 300;
//name = "example";
//...
</script>
<script type="text/javascript" src="thefile.js"></script>
Run Code Online (Sandbox Code Playgroud)
所以我可以添加更多变量
谢谢!
我是 python 新手,需要一些帮助。
我有一个变量
q = request.GET['q']
Run Code Online (Sandbox Code Playgroud)
如何在其中插入变量q:
url = "http://search.com/search?term="+q+"&location=sf"
Run Code Online (Sandbox Code Playgroud)
现在我不确定公约是什么?我习惯了 PHP 或 javascript,但我正在学习 python,如何动态插入变量?
如果我有两个 div 元素,用户可以在两个选项之间进行选择。
我想表明用户已单击它,因此当用户单击某个元素时,该类会添加一些样式。
现在我只掌握了基础知识。用户只能选择两个元素之一。因此,如果用户已经单击了一个元素,就会出现样式。如果用户决定单击另一个元素,则先前的单击将被删除,然后在新的单击上添加样式。
$(".ind").on("click", ->
$(this).toggleClass("selected")
);
Run Code Online (Sandbox Code Playgroud)
希望有人能指导一下,谢谢!
我正在关注RyanB的多态关联视频,该视频显示了实施评论系统的示例.
http://railscasts.com/episodes/154-polymorphic-association-revised?autoplay=true
我想知道如何将用户名添加到创建新评论的人的数据库中?这样我可以在视图页面中显示用户名,
谢谢
我正在尝试创建一个表单,以便我可以更新用户的内容信息,但我的表单没有显示.
我在views/admin/dashboard/index.html.erb中的表单:
<% form_for @admin do |f| %>
... form content...
<% end %>
Run Code Online (Sandbox Code Playgroud)
这是我在controller/admin/dashboard_controller.rb中的控制器
class Admin::DashboardController < ApplicationController
def index
@users = User.all
@admin = User.new
end
end
Run Code Online (Sandbox Code Playgroud)
这是我的模型:models/admin.rb
class Admin < ActiveRecord::Base
belongs_to :user
end
Run Code Online (Sandbox Code Playgroud)
然后在我的用户模型中:models/user.rb
class User < ActiveRecord::Base
has_many :admins
end
Run Code Online (Sandbox Code Playgroud) ruby ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 ruby-on-rails-3.2