-1

How can I include jQuery and bootstrap libraries in codeigniter? I am new with codeigniter , tried to watch some videos in youtube , but nothing , thank u

3
  • 3
    Possible duplicate of include css js in view page of codeigniter Commented May 18, 2017 at 21:16
  • Have you try to use 'em in reqular html file? Commented May 19, 2017 at 2:50
  • Have you set your base_url in config.php? Commented May 19, 2017 at 10:33

2 Answers 2

0

Here's what you can do:

  1. First be sure to have installed and working CodeIgniter framework, first you have to see the "Welcome page" of the framework, and you have to get downloaded the files of jQuery and Bootstrap. After this, you have to create your view for example 'home.php' file in the application/views folder.

  2. Then try to show a view with HTML code in the browser, in your main controller place the next lines:

    class Inicio extends CI_Controller {
    
        public function __construct()
        {
            parent::__construct();
        }//
    
    
        public function index()
        {
            $this->load->view('home'); // The final path file of the view is application/views/home.php
        }
    }
    
  3. In your view file (home.php) you have to call the needed files to load jQuery and Bootstrap, for example:

    <!DOCTYPE html>
    <html lang="es">
    <head>
      <meta charset="utf-8" />
      <base href="http://yourdomain.com/">
      <!-- Bootstrap -->
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <script src="bootstrap-3.3.5-dist/js/bootstrap.min.js"></script>
      <link rel="stylesheet" href="bootstrap-3.3.5-dist/css/bootstrap.css">
      <!-- jQuery -->
      <script src="js/jquery-2.1.1.js"></script>
    </head>
    
  4. After this if your paths are correct, the files will be loaded.

So I recommend to you to read the starter tutorial of CodeIgniter (click here) and you can experiment with controllers and views first.

The paths of jQuery and Bootstrap may vary depending the version you've downloaded.

Sign up to request clarification or add additional context in comments.

Comments

0

add the following scripts and link in your view file.

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

please visit this link

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.