如何将下拉菜单的占位符作为第一个可见值?

时间:2016-05-26 11:01:47

标签: php html

我不希望它作为标签。 像这样的东西: enter image description here

但是,只要我点击一次,这个“价值”就会消失,实际值应该开始显示。

4 个答案:

答案 0 :(得分:1)



INFO 5/26/16 9:44 AM: liquibase: Successfully acquired change log lock
INFO 5/26/16 9:44 AM: liquibase: Reading from activiti.DATABASECHANGELOG
WARNING 5/26/16 9:44 AM: liquibase: modifyDataType will lose primary key/autoincrement/not null settings for mysql.  Use <sql> and re-specify all configuration if this$
SEVERE 5/26/16 9:44 AM: liquibase: classpath:META-INF/liquibase/db-changelog-onpremise.xml: classpath:META-INF/liquibase/db-changelog-onpremise.xml::1::tijsrademakers:$
liquibase.exception.DatabaseException: Table 'hibernate_sequences' already exists [Failed SQL: CREATE TABLE activiti.hibernate_sequences (sequence_name VARCHAR(255) NU$
        at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:316)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:122)
        at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1247)
        at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1230)
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:548)
        at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73)
        at liquibase.Liquibase.update(Liquibase.java:210)
        at liquibase.Liquibase.update(Liquibase.java:190)
        at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:434)
        at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:391)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at com.activiti.servlet.WebConfigurer.contextInitialized(WebConfigurer.java:85)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:939)

INFO 5/26/16 9:44 AM: liquibase: classpath:META-INF/liquibase/db-changelog-onpremise.xml::1::tijsrademakers: Successfully released change log lock
09:44:40,157 [localhost-startStop-1] WARN  org.springframework.web.context.support.AnnotationConfigWebApplicationContext  - Exception encountered during context initia$
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [com/activiti/conf/DatabaseConfigurat$
     Reason: liquibase.exception.DatabaseException: Table 'hibernate_sequences' already exists [Failed SQL: CREATE TABLE activiti.hibernate_sequences (sequence_name VA$
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at com.activiti.servlet.WebConfigurer.contextInitialized(WebConfigurer.java:85)

   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at com.activiti.servlet.WebConfigurer.contextInitialized(WebConfigurer.java:85)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:939)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1812)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set classpath:META-INF/liquibase/db-changelog-onpremise.xml::1::tijsrademakers:
     Reason: liquibase.exception.DatabaseException: Table 'hibernate_sequences' already exists [Failed SQL: CREATE TABLE activiti.hibernate_sequences (sequence_name VA$
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:584)
        at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73)
        at liquibase.Liquibase.update(Liquibase.java:210)
        at liquibase.Liquibase.update(Liquibase.java:190)
        at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:434)
        at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:391)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
        ... 23 more
Caused by: liquibase.exception.DatabaseException: Table 'hibernate_sequences' already exists [Failed SQL: CREATE TABLE activiti.hibernate_sequences (sequence_name VARC$
        at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:316)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:122)
        at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1247)
        at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1230)
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:548)
        ... 31 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'hibernate_sequences' already exists
&#13;
$('select').change(function() {
     if ($(this).children('option:first-child').is(':selected')) {
       $(this).addClass('ddplaceholder');
     } else {
      $(this).removeClass('ddplaceholder');
     }
    });
&#13;
.ddplaceholder{color: grey;}
select option:first-child{color: grey; display: none;}
select option{color: #555;} // bootstrap default color
&#13;
&#13;
&#13;

你需要添加一些jQuery /参见上面的例子。这就是你想要的。

答案 1 :(得分:0)

除此之外,您还可以使用脚本。您可以使用jquery在鼠标悬停时使用remove first child。

答案 2 :(得分:0)

您可以禁用并预先选择默认值。然后当用户点击时,请选择此选项。

<option selected="true" disabled="disabled">

答案 3 :(得分:0)

只需创建空选项

<option value="" disabled selected>Select Category</option>
<option value="" disabled selected>Select Item</option>
<option value="" disabled selected>Select Vencdor</option>